Skip to content

Fix redundant_readme lint for lower-priority README files#17208

Open
goutamadwant wants to merge 1 commit into
rust-lang:masterfrom
goutamadwant:fix-redundant-readme-inference
Open

Fix redundant_readme lint for lower-priority README files#17208
goutamadwant wants to merge 1 commit into
rust-lang:masterfrom
goutamadwant:fix-redundant-readme-inference

Conversation

@goutamadwant

Copy link
Copy Markdown

What does this PR try to resolve?

Closes #17206.

cargo::redundant_readme warned whenever package.readme matched any default README filename. That can be wrong when a higher-priority default README file also exists. For example, removing readme = "README.txt" while README.md is present would make Cargo infer README.md, changing the package metadata.

This changes the lint to compare the explicit readme value with the same package-root README inference helper used by manifest normalization, so the lint only fires when removing the field preserves the inferred README.

How to test and review this PR?

Added coverage for both sides of the inference behavior:

  • README.txt with README.md also present should not warn.
  • README.txt as the inferred default should still warn.

Commands run:

  • cargo fmt --check
  • cargo test -p cargo --test testsuite -- lints::redundant_readme
  • cargo test -p cargo --test testsuite -- lints::

@rustbot rustbot added A-manifest Area: Cargo.toml issues S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 12, 2026
@rustbot

rustbot commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @epage (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage, weihanglo

};

if !DEFAULT_README_FILES.contains(&readme.as_str()) {
if default_readme_from_package_root(pkg.root()).as_deref() != Some(readme) {

@epage epage Jul 13, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep the check of DEFAULT_README_FILES as a fast path?

View changes since the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-manifest Area: Cargo.toml issues S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cargo::redundant_readme false positive when having multiple readme candidates

3 participants