about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSantiago Pastorino <spastorino@gmail.com>2021-08-25 20:32:31 -0300
committerSantiago Pastorino <spastorino@gmail.com>2021-08-25 20:32:31 -0300
commit4fcae2c89113e0767ee066a42f418261cebdc4bd (patch)
tree455a3fe4d9f52b514958854526911510586ae09a
parent7b0e554ee2c94e9b3865a8c2d24d720224512dec (diff)
downloadrust-4fcae2c89113e0767ee066a42f418261cebdc4bd.tar.gz
rust-4fcae2c89113e0767ee066a42f418261cebdc4bd.zip
Add const and static TAIT tests
-rw-r--r--src/test/ui/type-alias-impl-trait/static-const-types.rs16
-rw-r--r--src/test/ui/type-alias-impl-trait/static-const-types.stderr33
2 files changed, 49 insertions, 0 deletions
diff --git a/src/test/ui/type-alias-impl-trait/static-const-types.rs b/src/test/ui/type-alias-impl-trait/static-const-types.rs
new file mode 100644
index 00000000000..f630d278335
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/static-const-types.rs
@@ -0,0 +1,16 @@
+#![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
+
+static FOO1: Foo = 22_u32;
+//~^ ERROR: mismatched types [E0308]
+const FOO2: Foo = 22_u32;
+//~^ ERROR: mismatched types [E0308]
+
+fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/static-const-types.stderr b/src/test/ui/type-alias-impl-trait/static-const-types.stderr
new file mode 100644
index 00000000000..72083d014fe
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/static-const-types.stderr
@@ -0,0 +1,33 @@
+error[E0308]: mismatched types
+  --> $DIR/static-const-types.rs:11:20
+   |
+LL | type Foo = impl Debug;
+   |            ---------- the expected opaque type
+...
+LL | static FOO1: Foo = 22_u32;
+   |                    ^^^^^^ expected opaque type, found `u32`
+   |
+   = note: expected opaque type `impl Debug`
+                     found type `u32`
+
+error[E0308]: mismatched types
+  --> $DIR/static-const-types.rs:13:19
+   |
+LL | type Foo = impl Debug;
+   |            ---------- the expected opaque type
+...
+LL | const FOO2: Foo = 22_u32;
+   |                   ^^^^^^ expected opaque type, found `u32`
+   |
+   = note: expected opaque type `impl Debug`
+                     found type `u32`
+
+error: could not find defining uses
+  --> $DIR/static-const-types.rs:8:12
+   |
+LL | type Foo = impl Debug;
+   |            ^^^^^^^^^^
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0308`.