File tree 2 files changed +48
-0
lines changed
2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( impl_trait_in_assoc_type) ]
2
+
3
+ trait Foo : Sized {
4
+ type Bar ;
5
+ type Gat < T : Foo > ;
6
+ fn foo ( self ) -> ( <Self as Foo >:: Gat < u32 > , <Self as Foo >:: Gat < Self > ) ;
7
+ }
8
+
9
+ impl Foo for u32 {
10
+ type Bar = ( ) ;
11
+ type Gat < T : Foo > = ( ) ;
12
+ fn foo ( self ) -> ( <Self as Foo >:: Gat < u32 > , <Self as Foo >:: Gat < Self > ) {
13
+ ( ( ) , ( ) )
14
+ }
15
+ }
16
+
17
+ impl Foo for ( ) {
18
+ type Bar = impl Sized ;
19
+ type Gat < T : Foo > = <T as Foo >:: Bar ;
20
+ // Because we encounter `Gat<u32>` first, we never walk into another `Gat`
21
+ // again, thus missing the opaque type that we could be defining.
22
+ fn foo ( self ) -> ( <Self as Foo >:: Gat < u32 > , <Self as Foo >:: Gat < Self > ) {
23
+ ( ( ) , ( ) )
24
+ //~^ ERROR: mismatched types
25
+ }
26
+ }
27
+
28
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0308]: mismatched types
2
+ --> $DIR/associated-type-undefine.rs:23:14
3
+ |
4
+ LL | type Bar = impl Sized;
5
+ | ---------- the expected opaque type
6
+ ...
7
+ LL | ((), ())
8
+ | ^^ expected opaque type, found `()`
9
+ |
10
+ = note: expected opaque type `<() as Foo>::Bar`
11
+ found unit type `()`
12
+ note: this item must have the opaque type in its signature in order to be able to register hidden types
13
+ --> $DIR/associated-type-undefine.rs:22:8
14
+ |
15
+ LL | fn foo(self) -> (<Self as Foo>::Gat<u32>, <Self as Foo>::Gat<Self>) {
16
+ | ^^^
17
+
18
+ error: aborting due to 1 previous error
19
+
20
+ For more information about this error, try `rustc --explain E0308`.
You can’t perform that action at this time.
0 commit comments