Provide users with a way to mark uses as irrelevant for unused code lints
Open
@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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.