Skip to content

Commit dbadab5

Browse files
committed
Add type of a let tait test impl trait straight in let
1 parent 08e20d9 commit dbadab5

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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`.

0 commit comments

Comments
 (0)