rust-lang / rust-lang/rust

Provide users with a way to mark uses as irrelevant for unused code lints

Open
#160,621 5 comments 1 reaction 1 assignee View on GitHub

@josetorrs is already working on this.

Since Aug 6, 2026.

E-medium E-mentor
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

See https://github.com/tokio-rs/tracing/issues/2209 for a concrete bug this would fix.

This is related to Debug and Clone impls where we already have such a special case. I would like to generalize this to a #[diagnostics::] attribute usable on stable.

#[derive(Debug)]
pub struct Foo {
    field: u32,
}

pub fn bar(x: Foo) {
    println!("{x:?}");
}
warning: field `field` is never read
 --> src/lib.rs:3:5
  |
2 | pub struct Foo {
  |            --- field in this struct
3 |     field: u32,
  |     ^^^^^
  |
  = note: `Foo` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

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.