Rust / Cargo
Merged upstreamCorrectnessMerged Jul 31, 2026

Fix manual_readme lint for lower-priority README files

Fixed Cargo's manual_readme manifest lint so it no longer warns when removing an explicit lower-priority README would change the package's inferred README metadata.

rust-lang/cargo · #17208

Problem

The lint treated any default README filename as redundant without checking Cargo's actual package-root inference order. With both README.md and README.txt present, removing readme = "README.txt" would silently switch package metadata to README.md while Cargo still suggested removal.

Approach

Changed the lint to compare the explicit readme value with the same README inference helper used by manifest normalization, then covered both the false-positive lower-priority README case and the still-valid inferred default case.

Impact and scope

  • Prevents Cargo from recommending a manifest edit that would alter published package metadata.
  • Aligns the diagnostic rule with Cargo's real README inference semantics instead of duplicating a looser filename check.
  • Improves confidence in the cargo-lints stabilization path by closing a manifest false positive with targeted regression coverage.

Validation

  • Added regression coverage for README.txt when a higher-priority README.md is also present.
  • Kept coverage for the valid warning path where README.txt is the inferred default.
  • Merged after maintainer review with cargo fmt and focused Cargo lint test commands documented in the PR.