about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/test/ui/type-alias-impl-trait/field-types.rs20
-rw-r--r--src/test/ui/type-alias-impl-trait/field-types.stderr21
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`.