Add type of a let tait test
This commit is contained in:
parent
47ab5f7ce2
commit
08e20d9b28
2 changed files with 96 additions and 0 deletions
29
src/test/ui/type-alias-impl-trait/type_of_a_let.rs
Normal file
29
src/test/ui/type-alias-impl-trait/type_of_a_let.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
#![feature(type_alias_impl_trait)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
// FIXME This should compile, but it currently doesn't
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
type Foo = impl Debug;
|
||||
//~^ ERROR: could not find defining uses
|
||||
|
||||
fn foo1() -> u32 {
|
||||
let x: Foo = 22_u32;
|
||||
//~^ ERROR: mismatched types [E0308]
|
||||
x
|
||||
//~^ ERROR: mismatched types [E0308]
|
||||
}
|
||||
|
||||
fn foo2() -> u32 {
|
||||
let x: Foo = 22_u32;
|
||||
//~^ ERROR: mismatched types [E0308]
|
||||
let y: Foo = x;
|
||||
same_type((x, y));
|
||||
y
|
||||
//~^ ERROR: mismatched types [E0308]
|
||||
}
|
||||
|
||||
fn same_type<T>(x: (T, T)) {}
|
||||
|
||||
fn main() {}
|
67
src/test/ui/type-alias-impl-trait/type_of_a_let.stderr
Normal file
67
src/test/ui/type-alias-impl-trait/type_of_a_let.stderr
Normal file
|
@ -0,0 +1,67 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/type_of_a_let.rs:12:18
|
||||
|
|
||||
LL | type Foo = impl Debug;
|
||||
| ---------- the expected opaque type
|
||||
...
|
||||
LL | let x: Foo = 22_u32;
|
||||
| --- ^^^^^^ expected opaque type, found `u32`
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected opaque type `impl Debug`
|
||||
found type `u32`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/type_of_a_let.rs:14:5
|
||||
|
|
||||
LL | type Foo = impl Debug;
|
||||
| ---------- the found opaque type
|
||||
...
|
||||
LL | fn foo1() -> u32 {
|
||||
| --- expected `u32` because of return type
|
||||
...
|
||||
LL | x
|
||||
| ^ expected `u32`, found opaque type
|
||||
|
|
||||
= note: expected type `u32`
|
||||
found opaque type `impl Debug`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/type_of_a_let.rs:19:18
|
||||
|
|
||||
LL | type Foo = impl Debug;
|
||||
| ---------- the expected opaque type
|
||||
...
|
||||
LL | let x: Foo = 22_u32;
|
||||
| --- ^^^^^^ expected opaque type, found `u32`
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected opaque type `impl Debug`
|
||||
found type `u32`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/type_of_a_let.rs:23:5
|
||||
|
|
||||
LL | type Foo = impl Debug;
|
||||
| ---------- the found opaque type
|
||||
...
|
||||
LL | fn foo2() -> u32 {
|
||||
| --- expected `u32` because of return type
|
||||
...
|
||||
LL | y
|
||||
| ^ expected `u32`, found opaque type
|
||||
|
|
||||
= note: expected type `u32`
|
||||
found opaque type `impl Debug`
|
||||
|
||||
error: could not find defining uses
|
||||
--> $DIR/type_of_a_let.rs:8:12
|
||||
|
|
||||
LL | type Foo = impl Debug;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
Loading…
Add table
Reference in a new issue