rust-lang / rust-lang/rust

Lint unused assoc types although the trait is used

Open
#127,673 1 comment 0 reactions 1 assignee View on GitHub

@mu001999 is already working on this.

Since Jul 13, 2024.

A-associated-items A-lints C-bug L-dead_code T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.