Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mu001999 opened this issue Jun 20, 2024 · 1 comment · May be fixed by #128637
Open

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

mu001999 opened this issue Jun 20, 2024 · 1 comment · May be fixed by #128637
Labels
A-diagnostics Area: Messages for errors, warnings, and lints F-associated_const_equality `#![feature(associated_const_equality)]` L-dead_code Lint: dead_code T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@mu001999
Copy link
Contributor

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 mu001999 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 20, 2024
@mu001999
Copy link
Contributor Author

@rustbot label +L-dead_code +F-associated_const_equality

@rustbot rustbot added F-associated_const_equality `#![feature(associated_const_equality)]` L-dead_code Lint: dead_code labels Jun 20, 2024
@fmease fmease changed the title Associated constants used in equality should be considered as used Associated constants used in equality constraints should be considered as used Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints F-associated_const_equality `#![feature(associated_const_equality)]` L-dead_code Lint: dead_code T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
2 participants