Skip to content

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

New issue

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

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

Already on GitHub? # to your account

Open
mu001999 opened this issue Jun 20, 2024 · 1 comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. 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
@fmease fmease added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. and removed A-diagnostics Area: Messages for errors, warnings, and lints labels Jan 12, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. 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
3 participants