Skip to content

Commit 08e20d9

Browse files
committed
Add type of a let tait test
1 parent 47ab5f7 commit 08e20d9

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#![feature(type_alias_impl_trait)]
2+
#![allow(dead_code)]
3+
4+
// FIXME This should compile, but it currently doesn't
5+
6+
use std::fmt::Debug;
7+
8+
type Foo = impl Debug;
9+
//~^ ERROR: could not find defining uses
10+
11+
fn foo1() -> u32 {
12+
let x: Foo = 22_u32;
13+
//~^ ERROR: mismatched types [E0308]
14+
x
15+
//~^ ERROR: mismatched types [E0308]
16+
}
17+
18+
fn foo2() -> u32 {
19+
let x: Foo = 22_u32;
20+
//~^ ERROR: mismatched types [E0308]
21+
let y: Foo = x;
22+
same_type((x, y));
23+
y
24+
//~^ ERROR: mismatched types [E0308]
25+
}
26+
27+
fn same_type<T>(x: (T, T)) {}
28+
29+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/type_of_a_let.rs:12:18
3+
|
4+
LL | type Foo = impl Debug;
5+
| ---------- the expected opaque type
6+
...
7+
LL | let x: Foo = 22_u32;
8+
| --- ^^^^^^ expected opaque type, found `u32`
9+
| |
10+
| expected due to this
11+
|
12+
= note: expected opaque type `impl Debug`
13+
found type `u32`
14+
15+
error[E0308]: mismatched types
16+
--> $DIR/type_of_a_let.rs:14:5
17+
|
18+
LL | type Foo = impl Debug;
19+
| ---------- the found opaque type
20+
...
21+
LL | fn foo1() -> u32 {
22+
| --- expected `u32` because of return type
23+
...
24+
LL | x
25+
| ^ expected `u32`, found opaque type
26+
|
27+
= note: expected type `u32`
28+
found opaque type `impl Debug`
29+
30+
error[E0308]: mismatched types
31+
--> $DIR/type_of_a_let.rs:19:18
32+
|
33+
LL | type Foo = impl Debug;
34+
| ---------- the expected opaque type
35+
...
36+
LL | let x: Foo = 22_u32;
37+
| --- ^^^^^^ expected opaque type, found `u32`
38+
| |
39+
| expected due to this
40+
|
41+
= note: expected opaque type `impl Debug`
42+
found type `u32`
43+
44+
error[E0308]: mismatched types
45+
--> $DIR/type_of_a_let.rs:23:5
46+
|
47+
LL | type Foo = impl Debug;
48+
| ---------- the found opaque type
49+
...
50+
LL | fn foo2() -> u32 {
51+
| --- expected `u32` because of return type
52+
...
53+
LL | y
54+
| ^ expected `u32`, found opaque type
55+
|
56+
= note: expected type `u32`
57+
found opaque type `impl Debug`
58+
59+
error: could not find defining uses
60+
--> $DIR/type_of_a_let.rs:8:12
61+
|
62+
LL | type Foo = impl Debug;
63+
| ^^^^^^^^^^
64+
65+
error: aborting due to 5 previous errors
66+
67+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)