Closed
Description
If I have code like this:
struct S<T> {
parent: Option<Box<S<T>>>
}
I get the following compiler error message:
error[E0392]: parameter `T` is never used
--> t.rs:12:10
|
12 | struct S<T> {
| ^ unused type parameter
|
= help: consider removing `T` or using a marker such as `std::marker::PhantomData`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0392`.
The error message is, IMHO, technically correct, but not necessarily helpful. Now, in this particular example, it's relatively obvious what the mistake is, but I stumbled across it while doing a refactoring that tweaked a complex enum
-- I was baffled for a while :) My intuitive explanation is that although I'm "using" T
by passing it recursively to S
I'm never "consuming" T
by attaching it to a concrete type.
I wonder if E0392 might want to be special cased / reworded to cover this particular case? I appreciate it's not a common one, but I'm probably not the first person to do something silly like this.