From bb583f72e3ac42997eaa3522eca54b5326483351 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 25 Aug 2021 20:07:12 -0300 Subject: [PATCH] Add field types tait tests --- .../ui/type-alias-impl-trait/field-types.rs | 20 ++++++++++++++++++ .../type-alias-impl-trait/field-types.stderr | 21 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/test/ui/type-alias-impl-trait/field-types.rs create mode 100644 src/test/ui/type-alias-impl-trait/field-types.stderr 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`.