diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2021-08-25 20:07:12 -0300 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2021-08-25 20:10:08 -0300 |
| commit | bb583f72e3ac42997eaa3522eca54b5326483351 (patch) | |
| tree | f3f63477f6ddb25e72f25ace550b7442d318d523 | |
| parent | 7b0e554ee2c94e9b3865a8c2d24d720224512dec (diff) | |
| download | rust-bb583f72e3ac42997eaa3522eca54b5326483351.tar.gz rust-bb583f72e3ac42997eaa3522eca54b5326483351.zip | |
Add field types tait tests
| -rw-r--r-- | src/test/ui/type-alias-impl-trait/field-types.rs | 20 | ||||
| -rw-r--r-- | src/test/ui/type-alias-impl-trait/field-types.stderr | 21 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/test/ui/type-alias-impl-trait/field-types.rs b/src/test/ui/type-alias-impl-trait/field-types.rs new file mode 100644 index 00000000000..91494a82d0f --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/field-types.rs @@ -0,0 +1,20 @@ +#![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 + +struct Bar { + foo: Foo, +} + +fn bar() -> Bar { + Bar { foo: "foo" } + //~^ ERROR: mismatched types [E0308] +} + +fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/field-types.stderr b/src/test/ui/type-alias-impl-trait/field-types.stderr new file mode 100644 index 00000000000..18c2abbdf37 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/field-types.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/field-types.rs:16:16 + | +LL | type Foo = impl Debug; + | ---------- the expected opaque type +... +LL | Bar { foo: "foo" } + | ^^^^^ expected opaque type, found `&str` + | + = note: expected opaque type `impl Debug` + found reference `&'static str` + +error: could not find defining uses + --> $DIR/field-types.rs:8:12 + | +LL | type Foo = impl Debug; + | ^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. |
