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

@rustbot

This comment has been minimized.

@goutamadwant
goutamadwant force-pushed the fix-redundant-readme-inference branch from 78244e6 to 1ee9f2d Compare July 17, 2026 19:34
@rustbot

This comment has been minimized.

@weihanglo

Copy link
Copy Markdown
Member

@goutamadwant thanks, though you might want to hold off until #17231 gets merged.

@rustbot

This comment has been minimized.

@goutamadwant
goutamadwant force-pushed the fix-redundant-readme-inference branch from 1ee9f2d to 6d32d91 Compare July 20, 2026 23:13
@rustbot

rustbot commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@goutamadwant

Copy link
Copy Markdown
Author

@weihanglo I see the PR #17231 merged and there were merge conflicts too - resolved them now, Let me know. Thanks!

Comment on lines +44 to +45
#[cargo_test]
fn lower_priority_readme() {

@epage epage Jul 22, 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.

Sorry, forgot to call out our contrib guide encourages a specific commit structure with tests where a commit is added with the test, showing a reproduction of the undesired behavior. The follow up commit with the fix then also updates the test to show the new behavior.

See also https://epage.github.io/dev/pr-style/#c-split

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

4 participants