about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2021-07-18 14:21:52 +0900
committerGitHub <noreply@github.com>2021-07-18 14:21:52 +0900
commit76300d52f7707a1e30e4d9ff83d25dcbb01d8338 (patch)
treea0853fc3fac27912c075b1ce5fbed6c2c5d55eb3
parent77d155973c6c22a0e1af49a4a9bac024f697851d (diff)
parent5e7fed1f35c1318092fc6bf6d25814026224af8a (diff)
downloadrust-76300d52f7707a1e30e4d9ff83d25dcbb01d8338.tar.gz
rust-76300d52f7707a1e30e4d9ff83d25dcbb01d8338.zip
Rollup merge of #86763 - JohnTitor:test-63355, r=oli-obk
Add a regression test for issue-63355

Closes #63355
r? ``@nikomatsakis``
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-63355.rs50
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-63355.stderr14
2 files changed, 64 insertions, 0 deletions
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
index 00000000000..8762d189c73
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/issue-63355.rs
@@ -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
index 00000000000..dc5370a2666
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/issue-63355.stderr
@@ -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`.