]> git.lizzy.rs Git - rust.git/commitdiff
Add some TAIT-related regression tests
authorYuki Okushi <yuki.okushi@huawei.com>
Thu, 29 Jul 2021 19:49:08 +0000 (04:49 +0900)
committerYuki Okushi <yuki.okushi@huawei.com>
Thu, 29 Jul 2021 19:49:08 +0000 (04:49 +0900)
src/test/ui/type-alias-impl-trait/issue-74280.rs [new file with mode: 0644]
src/test/ui/type-alias-impl-trait/issue-74280.stderr [new file with mode: 0644]
src/test/ui/type-alias-impl-trait/issue-77179.rs [new file with mode: 0644]
src/test/ui/type-alias-impl-trait/issue-77179.stderr [new file with mode: 0644]

diff --git a/src/test/ui/type-alias-impl-trait/issue-74280.rs b/src/test/ui/type-alias-impl-trait/issue-74280.rs
new file mode 100644 (file)
index 0000000..d5b90a4
--- /dev/null
@@ -0,0 +1,13 @@
+// Regression test for #74280.
+
+#![feature(type_alias_impl_trait)]
+
+type Test = impl Copy;
+
+fn test() -> Test {
+    let y = || -> Test { () };
+    //~^ ERROR: concrete type differs from previous defining opaque type use
+    7
+}
+
+fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/issue-74280.stderr b/src/test/ui/type-alias-impl-trait/issue-74280.stderr
new file mode 100644 (file)
index 0000000..79c7df7
--- /dev/null
@@ -0,0 +1,14 @@
+error: concrete type differs from previous defining opaque type use
+  --> $DIR/issue-74280.rs:8:13
+   |
+LL |     let y = || -> Test { () };
+   |             ^^^^^^^^^^^^^^^^^ expected `i32`, got `()`
+   |
+note: previous use here
+  --> $DIR/issue-74280.rs:7:1
+   |
+LL | fn test() -> Test {
+   | ^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/type-alias-impl-trait/issue-77179.rs b/src/test/ui/type-alias-impl-trait/issue-77179.rs
new file mode 100644 (file)
index 0000000..31c45a2
--- /dev/null
@@ -0,0 +1,14 @@
+// Regression test for #77179.
+
+#![feature(type_alias_impl_trait)]
+
+type Pointer<T> = impl std::ops::Deref<Target=T>;
+
+fn test() -> Pointer<_> {
+    //~^ ERROR: the type placeholder `_` is not allowed within types
+    Box::new(1)
+}
+
+fn main() {
+    test();
+}
diff --git a/src/test/ui/type-alias-impl-trait/issue-77179.stderr b/src/test/ui/type-alias-impl-trait/issue-77179.stderr
new file mode 100644 (file)
index 0000000..593aeea
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types
+  --> $DIR/issue-77179.rs:7:22
+   |
+LL | fn test() -> Pointer<_> {
+   |              --------^-
+   |              |       |
+   |              |       not allowed in type signatures
+   |              help: replace with the correct return type: `Box<i32>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0121`.