about summary refs log tree commit diff
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2021-08-26 12:38:15 -0700
committerGitHub <noreply@github.com>2021-08-26 12:38:15 -0700
commitaf549368f3c4062bb509e475652b287be17b6f2c (patch)
tree4375f794e245bdb3e897a4f3ba9b05e94dd36284
parentcb95e3650ad2584158ffcc8b13f2a55b48c1951c (diff)
parentbb583f72e3ac42997eaa3522eca54b5326483351 (diff)
downloadrust-af549368f3c4062bb509e475652b287be17b6f2c.tar.gz
rust-af549368f3c4062bb509e475652b287be17b6f2c.zip
Rollup merge of #88348 - spastorino:field-types-tait-test, r=oli-obk
Add field types tait tests

r? ```@oli-obk```

Related to #86727
-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`.