Skip to content

Fix duplicate diagnostics for min_rust_version_invalid_attr#17396

Open
Gri-ffin wants to merge 1 commit into
rust-lang:masterfrom
Gri-ffin:fix-msrv-dup
Open

Fix duplicate diagnostics for min_rust_version_invalid_attr#17396
Gri-ffin wants to merge 1 commit into
rust-lang:masterfrom
Gri-ffin:fix-msrv-dup

Conversation

@Gri-ffin

@Gri-ffin Gri-ffin commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

part of #12379

Separate attributes check from parsing.

changelog: [min_rust_version_invalid_attr]: fix duplicate diagnostics

@rustbot rustbot added S-waiting-on-community-reviews Status: This is awaiting for positive reviews from the community before a maintainer is assigned. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jul 10, 2026

@DanielEScherzer DanielEScherzer left a comment

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.

So this could just be me not understanding clippy, but if I put the code from the test case in the playground, the output there has all of the same errors that the updated test has - so it doesn't look like things were being duplicated previously? Or is something already suppressing the duplicates on the playground?

View changes since this review

@Gri-ffin

Copy link
Copy Markdown
Contributor Author

Yes, rustc will deduplicate the lints before outputting them, you can test locally by running cargo clippy -- -Zdeduplicate-diagnostics=no. You should be on nightly though.

@ada4a

ada4a commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

you can test locally by running cargo clippy -- -Zdeduplicate-diagnostics=no

I think cargo dev lint path/to/test.rs should work as well

@Gri-ffin

Copy link
Copy Markdown
Contributor Author

-Zdeduplicate-diagnostics is yes by default so you need to pass no.

Comment thread clippy_lints/src/attrs/mod.rs Outdated

mixed_attributes_style::check(cx, item.span, &item.attrs);
duplicated_attributes::check(cx, &item.attrs);
msrvs::check_attrs(cx.sess(), &item.attrs);

@ada4a ada4a Jul 10, 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.

But this means you'll need to manually add this line to any check_x where x can have attributes, no? So I think this is missing check_stmt, check_local, etc. Overall I'm unsure if this approach is very maintainable..

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I honestly was conflicted between this and moving the macro expansion of extract_msrv_attr! (meaning check_attributes and check_attributes_post) inside, which would duplicate code, plus I genuinely thought no one would ever put msrv attrs above stmts. But you are right, the second option is probably better instead of sprinkling checks here and there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm now that I'm reviewing the implementation, I think duplicated_attributes::check should also be moved.

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

Labels

S-waiting-on-community-reviews Status: This is awaiting for positive reviews from the community before a maintainer is assigned. 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.

4 participants