Skip to content

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

Closed
@Ltrlg

Description

@Ltrlg

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))

Activity

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)`)[/+] on May 17, 2023
clubby789

clubby789 commented on May 17, 2023

@clubby789
Contributor

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

self-assigned this
on May 17, 2023
added a commit that references this issue on May 26, 2023

Rollup merge of rust-lang#111714 - cjgillot:lint-expect-confusion, r=…

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

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @cjgillot@Ltrlg@clubby789

    Issue actions

      `unused_attributes` false positive (top-level `unused_crate_dependencies` with `feature(lint_reasons)`) · Issue #111682 · rust-lang/rust