Open
Description
Consider the following code snippet playground
trait MyTrait<I> {}
trait SecondTrait {}
fn bar<A: MyTrait<B>, B: SecondTrait>() {}
struct MyStruct<A: MyTrait<B>, B: SecondTrait> {
field: A
}
This procudes the error:
error[E0392]: parameter `B` is never used
--> src/lib.rs:6:32
|
6 | struct MyStruct<A: MyTrait<B>, B: SecondTrait> {
| ^ unused type parameter
|
= help: consider removing `B` or using a marker such as `std::marker::PhantomData`
However, the parameter B
is used - it's part of how we bound A
.
The function and struct are equivalent in terms of generic parameters - since the equalivalent function compiles, the struct should as well.
Though this can be worked around via PhantomData
, there's no reason to require using it. The struct definition is perfectly valid and useful, and should be useable without any workarounds.