Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Incorrect clippy::useless_attribute for hidden_glob_reexports #11595

Closed
kawadakk opened this issue Oct 2, 2023 · 0 comments · Fixed by #12755
Closed

Incorrect clippy::useless_attribute for hidden_glob_reexports #11595

kawadakk opened this issue Oct 2, 2023 · 0 comments · Fixed by #12755
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@kawadakk
Copy link

kawadakk commented Oct 2, 2023

Summary

hidden_glob_reexports is valid on use items.

Lint Name

useless_attribute

Reproducer

I tried this code:

#![allow(dead_code)]
#![allow(unused_imports)]

mod foo1 {
    pub struct Foo;
    pub use Foo as Bar;
}

mod foo2 {
    pub struct Foo;
}

pub use foo1::*;

// #[allow(clippy::useless_attribute)]
#[allow(hidden_glob_reexports)]
use foo2::Foo as Bar;

I saw this happen:

error: useless lint attribute
  --> src/lib.rs:16:1
   |
16 | #[allow(hidden_glob_reexports)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(hidden_glob_reexports)]`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_attribute
   = note: `#[deny(clippy::useless_attribute)]` on by default

error: could not compile `ice` (lib) due to previous error

I expected to see this happen: No errors because hidden_glob_reexports lint would be generated without it:

warning: private item shadows public glob re-export
  --> src/lib.rs:17:5
   |
17 | use foo2::Foo as Bar;
   |     ^^^^^^^^^^^^^^^^
   |
note: the name `Bar` in the type namespace is supposed to be publicly re-exported here
  --> src/lib.rs:13:9
   |
13 | pub use foo1::*;
   |         ^^^^^^^
note: but the private item here shadows it
  --> src/lib.rs:17:5
   |
17 | use foo2::Foo as Bar;
   |     ^^^^^^^^^^^^^^^^
   = note: `#[warn(hidden_glob_reexports)]` on by default

Version

rustc 1.75.0-nightly (e0d7ed1f4 2023-10-01)
binary: rustc
commit-hash: e0d7ed1f453fb54578cc96dfea859b0e7be15016
commit-date: 2023-10-01
host: x86_64-unknown-linux-gnu
release: 1.75.0-nightly
LLVM version: 17.0.2

Additional Labels

No response

@kawadakk kawadakk added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Oct 2, 2023
9999years added a commit to 9999years/rust-clippy that referenced this issue May 2, 2024
bors added a commit that referenced this issue May 6, 2024
…umeGomez

Allow more attributes in `clippy::useless_attribute`

Fixes #12753
Fixes #4467
Fixes #11595
Fixes #10878

changelog: [`useless_attribute`]: Attributes allowed on `use` items now include `ambiguous_glob_exports`, `hidden_glob_reexports`, `dead_code`, `unused_braces`, and `clippy::disallowed_types`.
@bors bors closed this as completed in 96e69d9 May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant