You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use std::fmt::Debug;pubmod a {pubtypeA = ();pubmod b {pubtypeB = ();}}fnbuild(){let a: a::A = unimplemented!();let b: a::b::B = unimplemented!();println!("{:?} {:?}", a, b);}// the same code as above, just implemented with traitstraitModA{typeA:Debug;typeB:ModB;}traitModB{typeB:Debug;}fnbuild2<A:ModA>(){let a:A::A = unimplemented!();// works just finelet b:A::B::B = unimplemented!();// fails to compileprintln!("{:?} {:?}", a, b)}
I expected to compile it without errors.
Instead, this happened:
error[E0223]: ambiguous associated type
--> src/main.rs:28:12
|
28 | let b:A::B::B = unimplemented!();// fails to compile
| ^^^^^^^ help:use fully-qualified syntax: `<<AasModA>::BasTrait>::B`
The problem here is that we're attempting to take the type of X from MyTrait. Unfortunately, the type of X is not defined, because it's only made concrete in implementations of the trait.
This obviously doesn't apply here - B is as concrete as A. And the type A::B::B is just as specific as A::A and A::B, yet only the former fails to compile!
The text was updated successfully, but these errors were encountered:
I tried this code:
I expected to compile it without errors.
Instead, this happened:
E0223 states:
This obviously doesn't apply here -
B
is as concrete asA
. And the typeA::B::B
is just as specific asA::A
andA::B
, yet only the former fails to compile!The text was updated successfully, but these errors were encountered: