Closed
Description
Given the following code: play
trait A {
type X;
}
trait B: A {
type X; // note: this is legal
}
impl<X> Clone for Box<dyn B<X=X, X=X>> {
fn clone(&self) -> Self {
todo!()
}
}
The current output is:
error[E0719]: the value of the associated type `X` (from trait `B`) is already specified
--> src/lib.rs:9:34
|
9 | impl<X> Clone for Box<dyn B<X=X, X=X>> {
| --- ^^^ re-bound here
| |
| `X` bound here first
error[E0191] the value of the associated type `X` (from trait `A`) must be specified
--> src/lib.rs:9:27
|
2 | type X;
| ------- `X` defined here
...
9 | impl<X> Clone for Box<dyn B<X=X, X=X>> {
| ^^^^^^^^^^^ help: specify the associated type: `B<X=X, X=X, X = Type>`
B<X=X, X=X, X = Type>
is wrong, specifying another X=Type
isn't going to fix the problem.
Writing just dyn B
has a suggestion consider introducing a new type parameter, adding `where` constraints using the fully-qualified path to the associated types
, which is good, but the concrete syntax would be nice.
Activity
compiler-errors commentedon Aug 3, 2022
We probably should modify E0191 to hint that an supertrait's associated type is shadowed. I think E0719 here is fine to keep as-is, imo.
jendrikw commentedon Aug 3, 2022
I agree the message for E0719 is good as-is.
Abhicodes-crypto commentedon Dec 5, 2022
Is this issue fixed ? If not can I take this up, please.
Also how exactly should E0191 be modified. Imo, I don't think E0191 should pop up in this case as E0719 conveys the message. @compiler-errors
Abhicodes-crypto commentedon Dec 6, 2022
@rustbot claim
LittleFall commentedon Feb 22, 2023
@rustbot claim
LittleFall commentedon Feb 26, 2023
Ask for help:
How do I specify the association type of supertrait with the same name? In other words, is there an easy way to modify the code in the issue to make it pass compilation?
Here's my clumsy way of creating a new trait.
14 remaining items