-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Assignees
@Dino1694
Description
Grow2 is a generic alias of Grow1, but using the alias on the starred(*) line does not work.
I tried this code:
#![feature(trait_alias)] trait Tree { type Fruit; } trait Grow1<T: Tree> { fn grow(x: T); } trait Grow2<T: Tree> = Grow1<T>; struct AppleTree; struct Apple; impl Tree for AppleTree { type Fruit = Apple; } type GrowAppleTree1 = dyn Grow1<AppleTree>; // semantically identical to the above line, but doesn't compile type GrowAppleTree2 = dyn Grow2<AppleTree>; // (*) fn main() {}
I expected to see this happen:
Compilation success
Instead, this happened:
error[E0191]: the value of the associated type `Fruit` in `Tree` must be specified --> ..\..\rust\trait_alias_bug.rs:15:27 | 3 | type Fruit; | ---------- `Fruit` defined here ... 15 | type GrowAppleTree2 = dyn Grow2<AppleTree>; | ^^^^^^^^^^^^^^^^ help: specify the associated type: `Grow2<AppleTree, Fruit = Type>` error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0191`.
Meta
rustc --version --verbose
:
rustc 1.78.0-nightly (b6d2d841b 2024年03月05日)