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

unused_attributes false positive (top-level unused_crate_dependencies with feature(lint_reasons)) #111682

Closed
Ltrlg opened this issue May 17, 2023 · 1 comment · Fixed by #111714
Assignees
Labels
C-bug Category: This is a bug.

Comments

@Ltrlg
Copy link

Ltrlg commented May 17, 2023

I tried this code:

#![deny(unused_crate_dependencies)]
#![feature(lint_reasons)]

fn main() {}

unused_crate_dependencies is at top level, as expected. But I get the following warning:

warning: deny(unused_crate_dependencies) is ignored unless specified at crate level
 --> src/main.rs:1:9
  |
1 | #![deny(unused_crate_dependencies)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_attributes)]` on by default

Removing the #[feature(lint_reason)] removes the warning.

Interestingly, adding a #[deny(…)] removes the warning too:

#![deny(unused_crate_dependencies)]
#![deny(non_snake_case)]
#![feature(lint_reasons)]

fn main() {}

gives no warning.

But only at certain positions:

#![deny(non_snake_case)]
#![deny(unused_crate_dependencies)]
#![feature(lint_reasons)]

fn main() {}

gives the warning.

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (ce5919fce 2023-05-15)
binary: rustc
commit-hash: ce5919fcef67103098219e1868f741e56fc90963
commit-date: 2023-05-15
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2

(But IIRC I had the warning already with 1.71.0-nightly (473f916d8 2023-05-03))

@Ltrlg Ltrlg added the C-bug Category: This is a bug. label May 17, 2023
@Ltrlg Ltrlg changed the title unused_attributes false positive (top-level unused_crate_dependencies) unused_attributes false positive (top-level unused_crate_dependencies with feature(lint_reasons)) May 17, 2023
@clubby789
Copy link
Contributor

Seems to happen while walking the crate checking for lint expectations. Regressed in #101620 cc @cjgillot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants