Open
Description
Code
struct Foo(usize);
fn get_thing<T>() -> T { todo!() }
pub fn foo() {
let Foo(_x) = get_thing();
// no warning if the type is explicitly used when calling get_thing
// let Foo(_x) = get_thing::<Foo>();
}
Current output
warning: struct `Foo` is never constructed
--> src/lib.rs:1:8
|
1 | struct Foo(usize);
| ^^^
|
= note: `#[warn(dead_code)]` on by default
Desired output
(nothing)
Rationale and extra context
For context, the specific "get_thing" function I originally ran into this was with zerocopy::FromBytes::read_from_bytes
.
Other cases
Rust Version
$ rustc --version --verbose
rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: x86_64-unknown-linux-gnu
release: 1.82.0
LLVM version: 19.1.1
Anything else?
No response