Skip to content

useless_attribute incorrectly triggers for unknown tool attributes on use #13764

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
lcnr opened this issue Nov 30, 2024 · 0 comments · Fixed by #13766
Closed

useless_attribute incorrectly triggers for unknown tool attributes on use #13764

lcnr opened this issue Nov 30, 2024 · 0 comments · Fixed by #13766

Comments

@lcnr
Copy link
Contributor

lcnr commented Nov 30, 2024

Description

rust-lang/rust#133643 failed in CI due to an false positive of the useless_attribute lint.

https://github.com/rust-lang/rust/actions/runs/12088915947/job/33713323311

To repro, use the following inside of rustc_middle:

#[allow(rustc::non_glob_import_of_type_ir_inherent)]
use rustc_type_ir::inherent::SliceLike;

This results in

  error: useless lint attribute
    --> compiler/rustc_middle/src/ty/mod.rs:29:1
     |
  29 | #[allow(rustc::non_glob_import_of_type_ir_inherent)]
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(rustc::non_glob_import_of_type_ir_inherent)]`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_attribute
     = note: `-D clippy::useless-attribute` implied by `-D clippy::correctness`
     = help: to override `-D clippy::correctness` add `#[allow(clippy::useless_attribute)]`

I can imagine us adding an allow-list for lints in the rustc-namespace, however, I believe that in general, this lint should never trigger for lints from unknown namespaces.

github-merge-queue bot pushed a commit that referenced this issue Dec 17, 2024
Fixes #13764

changelog: [`useless_attribute`]: do not trigger on attributes with
unknown namespace
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant