]> git.lizzy.rs Git - rust.git/commitdiff
Add a regression test for issue-63355
authorYuki Okushi <yuki.okushi@huawei.com>
Wed, 30 Jun 2021 23:00:21 +0000 (08:00 +0900)
committerYuki Okushi <yuki.okushi@huawei.com>
Wed, 30 Jun 2021 23:00:21 +0000 (08:00 +0900)
src/test/ui/type-alias-impl-trait/issue-63355.rs [new file with mode: 0644]
src/test/ui/type-alias-impl-trait/issue-63355.stderr [new file with mode: 0644]

diff --git a/src/test/ui/type-alias-impl-trait/issue-63355.rs b/src/test/ui/type-alias-impl-trait/issue-63355.rs
new file mode 100644 (file)
index 0000000..8762d18
--- /dev/null
@@ -0,0 +1,50 @@
+#![feature(min_type_alias_impl_trait)]
+#![feature(type_alias_impl_trait)]
+#![allow(incomplete_features)]
+
+pub trait Foo {}
+
+pub trait Bar {
+    type Foo: Foo;
+
+    fn foo() -> Self::Foo;
+}
+
+pub trait Baz {
+    type Foo: Foo;
+    type Bar: Bar<Foo = Self::Foo>;
+
+    fn foo() -> Self::Foo;
+    fn bar() -> Self::Bar;
+}
+
+impl Foo for () {}
+
+impl Bar for () {
+    type Foo = FooImpl;
+
+    fn foo() -> Self::Foo {
+        ()
+    }
+}
+
+// FIXME(#86731): The below is illegal use of `min_type_alias_impl_trait`
+// but the compiler doesn't report it, we should fix it.
+pub type FooImpl = impl Foo;
+pub type BarImpl = impl Bar<Foo = FooImpl>;
+//~^ ERROR: type mismatch resolving `<() as Bar>::Foo == ()`
+
+impl Baz for () {
+    type Foo = FooImpl;
+    type Bar = BarImpl;
+
+    fn foo() -> Self::Foo {
+        ()
+    }
+
+    fn bar() -> Self::Bar {
+        ()
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/issue-63355.stderr b/src/test/ui/type-alias-impl-trait/issue-63355.stderr
new file mode 100644 (file)
index 0000000..dc5370a
--- /dev/null
@@ -0,0 +1,14 @@
+error[E0271]: type mismatch resolving `<() as Bar>::Foo == ()`
+  --> $DIR/issue-63355.rs:34:20
+   |
+LL | pub type FooImpl = impl Foo;
+   |                    -------- the found opaque type
+LL | pub type BarImpl = impl Bar<Foo = FooImpl>;
+   |                    ^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found opaque type
+   |
+   = note: expected unit type `()`
+            found opaque type `impl Foo`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0271`.