rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.59k stars 12.74k forks source link

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

Open mu001999 opened 4 months ago

mu001999 commented 4 months ago

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

mu001999 commented 4 months ago

@rustbot label +L-dead_code +F-associated_const_equality