diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2021-08-26 12:38:12 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-26 12:38:12 -0700 |
| commit | 0f7dc5db4543fbfd54db042a084b630fa5dced53 (patch) | |
| tree | 9abab31c9b38231051db1eb231c62f3f1fb367eb /src/test | |
| parent | c418a48737a3d7b18c090ed1ae605f5e0561c1b3 (diff) | |
| parent | 4924e34526cc8098d36ad60ed974dbe6484ac519 (diff) | |
| download | rust-0f7dc5db4543fbfd54db042a084b630fa5dced53.tar.gz rust-0f7dc5db4543fbfd54db042a084b630fa5dced53.zip | |
Rollup merge of #88332 - spastorino:argument-types-tait-test, r=oli-obk
Add argument types tait tests r? ``@oli-obk`` Related to #86727
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/type-alias-impl-trait/argument-types.rs | 28 | ||||
| -rw-r--r-- | src/test/ui/type-alias-impl-trait/argument-types.stderr | 15 |
2 files changed, 43 insertions, 0 deletions
diff --git a/src/test/ui/type-alias-impl-trait/argument-types.rs b/src/test/ui/type-alias-impl-trait/argument-types.rs new file mode 100644 index 00000000000..8427b5b1fe8 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/argument-types.rs @@ -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()); +} diff --git a/src/test/ui/type-alias-impl-trait/argument-types.stderr b/src/test/ui/type-alias-impl-trait/argument-types.stderr new file mode 100644 index 00000000000..1cbf9c95d31 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/argument-types.stderr @@ -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`. |
