File tree 2 files changed +46
-0
lines changed
src/test/ui/type-alias-impl-trait
2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( type_alias_impl_trait) ]
2
+ #![ allow( dead_code) ]
3
+
4
+ // FIXME This should be under a feature flag
5
+
6
+ use std:: fmt:: Debug ;
7
+
8
+ fn foo1 ( ) -> u32 {
9
+ let x: impl Debug = 22_u32 ;
10
+ //~^ ERROR: `impl Trait` not allowed outside of function and method return types [E0562]
11
+ x // ERROR: we only know x: Debug, we don't know x = u32
12
+ }
13
+
14
+ fn foo2 ( ) -> u32 {
15
+ let x: impl Debug = 22_u32 ;
16
+ //~^ ERROR: `impl Trait` not allowed outside of function and method return types [E0562]
17
+ let y: impl Debug = x;
18
+ //~^ ERROR: `impl Trait` not allowed outside of function and method return types [E0562]
19
+ same_type ( ( x, y) ) ; // ERROR
20
+ x
21
+ }
22
+
23
+ fn same_type < T > ( x : ( T , T ) ) { }
24
+
25
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0562]: `impl Trait` not allowed outside of function and method return types
2
+ --> $DIR/type_of_a_let2.rs:9:12
3
+ |
4
+ LL | let x: impl Debug = 22_u32;
5
+ | ^^^^^^^^^^
6
+
7
+ error[E0562]: `impl Trait` not allowed outside of function and method return types
8
+ --> $DIR/type_of_a_let2.rs:15:12
9
+ |
10
+ LL | let x: impl Debug = 22_u32;
11
+ | ^^^^^^^^^^
12
+
13
+ error[E0562]: `impl Trait` not allowed outside of function and method return types
14
+ --> $DIR/type_of_a_let2.rs:17:12
15
+ |
16
+ LL | let y: impl Debug = x;
17
+ | ^^^^^^^^^^
18
+
19
+ error: aborting due to 3 previous errors
20
+
21
+ For more information about this error, try `rustc --explain E0562`.
You can’t perform that action at this time.
0 commit comments