about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-10-26 19:32:46 +0200
committerGitHub <noreply@github.com>2021-10-26 19:32:46 +0200
commitfcc9a9a9285a67d7afcacc27cbdc71f8dcec7ef3 (patch)
tree086b0a77d21cd7b5939b4b802f9ea81366a99bd3
parent40d3819a3c161de04d9acdfb29eb2153aee2a1ad (diff)
parentf9344296c15308ed37c0fcc584f4174b332648cf (diff)
downloadrust-fcc9a9a9285a67d7afcacc27cbdc71f8dcec7ef3.tar.gz
rust-fcc9a9a9285a67d7afcacc27cbdc71f8dcec7ef3.zip
Rollup merge of #90305 - vandenheuvel:test_issue_87258, r=Mark-Simulacrum
Add regression test for #87258

Closes #87258.
-rw-r--r--src/test/ui/generic-associated-types/issue-87258_a.rs24
-rw-r--r--src/test/ui/generic-associated-types/issue-87258_a.stderr11
-rw-r--r--src/test/ui/generic-associated-types/issue-87258_b.rs26
-rw-r--r--src/test/ui/generic-associated-types/issue-87258_b.stderr11
4 files changed, 72 insertions, 0 deletions
diff --git a/src/test/ui/generic-associated-types/issue-87258_a.rs b/src/test/ui/generic-associated-types/issue-87258_a.rs
new file mode 100644
index 00000000000..d9d17751fa6
--- /dev/null
+++ b/src/test/ui/generic-associated-types/issue-87258_a.rs
@@ -0,0 +1,24 @@
+#![feature(type_alias_impl_trait)]
+#![feature(generic_associated_types)]
+
+// See https://github.com/rust-lang/rust/issues/87258#issuecomment-883293367
+
+trait Trait1 {}
+
+struct Struct<'b>(&'b ());
+
+impl<'d> Trait1 for Struct<'d> {}
+
+pub trait Trait2 {
+    type FooFuture<'a>: Trait1;
+    fn foo<'a>() -> Self::FooFuture<'a>;
+}
+
+impl<'c, S: Trait2> Trait2 for &'c mut S {
+    type FooFuture<'a> = impl Trait1;
+    fn foo<'a>() -> Self::FooFuture<'a> { //~ ERROR
+        Struct(unimplemented!())
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/generic-associated-types/issue-87258_a.stderr b/src/test/ui/generic-associated-types/issue-87258_a.stderr
new file mode 100644
index 00000000000..93513a4563f
--- /dev/null
+++ b/src/test/ui/generic-associated-types/issue-87258_a.stderr
@@ -0,0 +1,11 @@
+error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
+  --> $DIR/issue-87258_a.rs:19:21
+   |
+LL |     fn foo<'a>() -> Self::FooFuture<'a> {
+   |                     ^^^^^^^^^^^^^^^^^^^
+   |
+   = note: hidden type `Struct<'_>` captures lifetime '_#7r
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0700`.
diff --git a/src/test/ui/generic-associated-types/issue-87258_b.rs b/src/test/ui/generic-associated-types/issue-87258_b.rs
new file mode 100644
index 00000000000..b29a978f517
--- /dev/null
+++ b/src/test/ui/generic-associated-types/issue-87258_b.rs
@@ -0,0 +1,26 @@
+#![feature(type_alias_impl_trait)]
+#![feature(generic_associated_types)]
+
+// See https://github.com/rust-lang/rust/issues/87258#issuecomment-883293367
+
+trait Trait1 {}
+
+struct Struct<'b>(&'b ());
+
+impl<'d> Trait1 for Struct<'d> {}
+
+pub trait Trait2 {
+    type FooFuture<'a>: Trait1;
+    fn foo<'a>() -> Self::FooFuture<'a>;
+}
+
+type Helper<'xenon, 'yttrium, KABOOM: Trait2> = impl Trait1;
+
+impl<'c, S: Trait2> Trait2 for &'c mut S {
+    type FooFuture<'a> = Helper<'c, 'a, S>;
+    fn foo<'a>() -> Self::FooFuture<'a> { //~ ERROR
+        Struct(unimplemented!())
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/generic-associated-types/issue-87258_b.stderr b/src/test/ui/generic-associated-types/issue-87258_b.stderr
new file mode 100644
index 00000000000..e077a423400
--- /dev/null
+++ b/src/test/ui/generic-associated-types/issue-87258_b.stderr
@@ -0,0 +1,11 @@
+error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
+  --> $DIR/issue-87258_b.rs:21:21
+   |
+LL |     fn foo<'a>() -> Self::FooFuture<'a> {
+   |                     ^^^^^^^^^^^^^^^^^^^
+   |
+   = note: hidden type `Struct<'_>` captures lifetime '_#7r
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0700`.