Skip to content

#[expect(unused_imports)] does not work correctly on grouped imports #127884

Closed
@vxpm

Description

@vxpm

the following snippet:

#[expect(unused_imports)]
use std::{io, fs};

results in the following compiler output:

warning: this lint expectation is unfulfilled
 --> src/main.rs:2:10
  |
2 | #[expect(unused_imports)]
  |          ^^^^^^^^^^^^^^
  |
  = note: ​`#[warn(unfulfilled_lint_expectations)]​` on by default

but removing the #[expect] results in:

warning: unused imports: ​`fs​` and ​`io​`
 --> src/main.rs:2:11
  |
2 | use std::{io, fs};
  |           ^^  ^^
  |
  = note: ​`#[warn(unused_imports)]​` on by default

so it is, indeed, supressing the lint - which means the first warning is wrong. it is important to note that the same does not happen on imports of a single item.

rustc version:

rustc 1.81.0-nightly (24d2ac0b5 2024-07-15)
binary: rustc
commit-hash: 24d2ac0b56fcbde13d827745f66e73efb1e17156
commit-date: 2024-07-15
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.F-lint_reasons`#![feature(lint_reasons)]`L-unused_importsLint: unused_importsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions