Skip to content

unused_qualification breaks code for older rust versions #129306

Description

@EdJoPaTo

Code

// Cargo.toml: a rust-version <= 1.79 (while being on 1.80 or nightly)

#![warn(unused_qualifications)]

let align = core::mem::align_of::<u128>();
dbg!(align);

Current output

warning: unnecessary qualification
 --> src/main.rs:9:17
  |
9 |     let align = core::mem::align_of::<u128>();
  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: the lint level is defined here
 --> src/main.rs:2:9
  |
2 | #![warn(unused_qualifications, unused_imports)]
  |         ^^^^^^^^^^^^^^^^^^^^^
help: remove the unnecessary path segments
  |
9 -     let align = core::mem::align_of::<u128>();
9 +     let align = align_of::<u128>();
  |

Desired output

The lint should not be triggered as core::mem::align_of is only part of the prelude since 1.80 (see #123168)

Rationale and extra context

Adding use core::mem::align_of (or std::…) and using it that way will not trigger unused_imports (warn-by-default) on 1.80 which is somewhat weird. Applying the fixes for unused_qualifications changes the MSRV while unused_imports doesn't?

I somewhat expect this to be closed as won't fix as rustc itself doesn't care about cargo related settings?

Other cases

No response

Rust Version

rustc 1.80.1 (3f5fd8dd4 2024-08-06)
binary: rustc
commit-hash: 3f5fd8dd41153bc5fdca9427e9e05be2c767ba23
commit-date: 2024-08-06
host: x86_64-unknown-linux-gnu
release: 1.80.1
LLVM version: 18.1.7

Anything else?

No response

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Aug 20, 2024
  2. added
    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
    on Aug 20, 2024
  3. ChayimFriedman2 commented on Aug 20, 2024

    @ChayimFriedman2
    Contributor

    I don't think the Rust compiler considers the MSRV defined in Cargo.toml in any way (I think Clippy does, though).

  4. jieyouxu commented on May 1, 2025

    @jieyouxu
    Member

    Triage: I don't think this is actionable for rustc as the compiler does not consider MSRV in Cargo.toml.

  5. clubby789 commented on Jan 6, 2026

    @clubby789
    Contributor

    cc rust-lang/compiler-team#950 as a motivating example

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.L-unused_qualificationsLint: unused_qualificationsT-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