Add argument types tait tests
This commit is contained in:
parent
47ab5f7ce2
commit
4924e34526
2 changed files with 43 additions and 0 deletions
28
src/test/ui/type-alias-impl-trait/argument-types.rs
Normal file
28
src/test/ui/type-alias-impl-trait/argument-types.rs
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#![feature(type_alias_impl_trait)]
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
use std::fmt::Debug;
|
||||||
|
|
||||||
|
type Foo = impl Debug;
|
||||||
|
|
||||||
|
// FIXME: This should compile, but it currently doesn't
|
||||||
|
fn foo1(mut x: Foo) {
|
||||||
|
x = 22_u32;
|
||||||
|
//~^ ERROR: mismatched types [E0308]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo2(mut x: Foo) {
|
||||||
|
// no constraint on x
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo3(x: Foo) {
|
||||||
|
println!("{:?}", x);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo_value() -> Foo {
|
||||||
|
11_u32
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
foo3(foo_value());
|
||||||
|
}
|
15
src/test/ui/type-alias-impl-trait/argument-types.stderr
Normal file
15
src/test/ui/type-alias-impl-trait/argument-types.stderr
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/argument-types.rs:10:9
|
||||||
|
|
|
||||||
|
LL | type Foo = impl Debug;
|
||||||
|
| ---------- the expected opaque type
|
||||||
|
...
|
||||||
|
LL | x = 22_u32;
|
||||||
|
| ^^^^^^ expected opaque type, found `u32`
|
||||||
|
|
|
||||||
|
= note: expected opaque type `impl Debug`
|
||||||
|
found type `u32`
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0308`.
|
Loading…
Reference in a new issue