File tree 2 files changed +43
-0
lines changed
src/test/ui/type-alias-impl-trait
2 files changed +43
-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
+ use std:: fmt:: Debug ;
5
+
6
+ type Foo = impl Debug ;
7
+
8
+ // FIXME: This should compile, but it currently doesn't
9
+ fn foo1 ( mut x : Foo ) {
10
+ x = 22_u32 ;
11
+ //~^ ERROR: mismatched types [E0308]
12
+ }
13
+
14
+ fn foo2 ( mut x : Foo ) {
15
+ // no constraint on x
16
+ }
17
+
18
+ fn foo3 ( x : Foo ) {
19
+ println ! ( "{:?}" , x) ;
20
+ }
21
+
22
+ fn foo_value ( ) -> Foo {
23
+ 11_u32
24
+ }
25
+
26
+ fn main ( ) {
27
+ foo3 ( foo_value ( ) ) ;
28
+ }
Original file line number Diff line number Diff line change
1
+ error[E0308]: mismatched types
2
+ --> $DIR/argument-types.rs:10:9
3
+ |
4
+ LL | type Foo = impl Debug;
5
+ | ---------- the expected opaque type
6
+ ...
7
+ LL | x = 22_u32;
8
+ | ^^^^^^ expected opaque type, found `u32`
9
+ |
10
+ = note: expected opaque type `impl Debug`
11
+ found type `u32`
12
+
13
+ error: aborting due to previous error
14
+
15
+ For more information about this error, try `rustc --explain E0308`.
You can’t perform that action at this time.
0 commit comments