Skip to content

useless_attribute incorrectly triggers for unknown tool attributes on use #13764

Closed
@lcnr

Description

@lcnr

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions