Skip to content

Associated constants used in equality constraints should be considered as used #126729

@mu001999

Description

@mu001999

Code

#![feature(associated_const_equality)]

trait Tr {
    const I: i32;
}

impl Tr for () {
    const I: i32 = 1;
}

fn foo() -> impl Tr<I = 1> {}

fn main() {
    foo();
}

Current output

warning: associated constant `I` is never used
 --> src/main.rs:4:11
  |
3 | trait Tr {
  |       -- associated constant in this trait
4 |     const I: i32;
  |           ^
  |
  = note: `#[warn(dead_code)]` on by default

warning: `playground` (bin "playground") generated 1 warning


### Desired output

```Shell
No warning.

Rationale and extra context

No response

Other cases

No response

Rust Version

Build using the Nightly version: 1.81.0-nightly
(2024-06-19 d8a38b00024cd7156dea)

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.F-associated_const_equality`#![feature(associated_const_equality)]`L-dead_codeLint: dead_codeT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    Status

    To Do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions