Code
#[allow(dead_code)]
struct Foo;
impl Foo {
fn foo(&self) {}
}
Current output
warning: method `foo` is never used
--> src/lib.rs:5:8
|
4 | impl Foo {
| -------- method in this implementation
5 | fn foo(&self) {}
| ^^^
|
= note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default
Desired output
Rationale and extra context
Allowing on the impl block can suppress warning both on methods and types.
struct Foo;
#[allow(dead_code)]
impl Foo {
fn foo(&self) {}
}
But I think it's more intuitive to just allow on types.
Futhermore, considering that when we have dead types, no methods could be used. So maybe we can also suppress warnings for items in the impl block when there has been warnings for the type. 🤔
Other cases
Rust Version
Build using the Nightly version: 1.93.0-nightly
(2025-11-19 07bdbaedc63094281483)
Anything else?
No response
Code
Current output
Desired output
Rationale and extra context
Allowing on the impl block can suppress warning both on methods and types.
But I think it's more intuitive to just allow on types.
Futhermore, considering that when we have dead types, no methods could be used. So maybe we can also suppress warnings for items in the impl block when there has been warnings for the type. 🤔
Other cases
Rust Version
Anything else?
No response