Skip to content

Lint unused assoc types although the trait is used #127673

@mu001999

Description

@mu001999

Code

trait Tr {
    type X;
}

impl Tr for () {
    type X = Self;
}

fn foo() -> impl Tr {}

fn main() {
    foo();
}

Current output

No warning.

Desired output

warning: associated type `X` is never used
 --> src/main.rs:2:11
  |
1 | trait Tr {
  |       -- associated type in this trait
2 |     type X;
  |          ^
  |
  = note: `#[warn(dead_code)]` on by default

Rationale and extra context

No response

Other cases

No response

Rust Version

Build using the Nightly version: 1.81.0-nightly
(2024-07-12 c6727fc9b5c64cefa726)

Anything else?

No response

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-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