about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorJack Huey <31162821+jackh726@users.noreply.github.com>2022-01-09 23:53:57 -0500
committerJack Huey <31162821+jackh726@users.noreply.github.com>2022-01-10 00:29:06 -0500
commitad57295fc9f5b0c747ae4f72d6208ccf03b94b0b (patch)
tree380ba40b4e3b4e27d83bdf9b4904019451a5fb84 /src/test
parente012a191d768adeda1ee36a99ef8b92d51920154 (diff)
downloadrust-ad57295fc9f5b0c747ae4f72d6208ccf03b94b0b.tar.gz
rust-ad57295fc9f5b0c747ae4f72d6208ccf03b94b0b.zip
Elaborate param_env predicates when checking if type outlives involving projection holds
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/generic-associated-types/issue-92096.rs27
-rw-r--r--src/test/ui/generic-associated-types/issue-92096.stderr18
-rw-r--r--src/test/ui/generic-associated-types/issue-92280.rs26
3 files changed, 71 insertions, 0 deletions
diff --git a/src/test/ui/generic-associated-types/issue-92096.rs b/src/test/ui/generic-associated-types/issue-92096.rs
new file mode 100644
index 00000000000..6c81babc0bc
--- /dev/null
+++ b/src/test/ui/generic-associated-types/issue-92096.rs
@@ -0,0 +1,27 @@
+// edition:2018
+// check-fail
+// FIXME(generic_associated_types): this should pass, but we end up
+// essentially requiring that `for<'s> C: 's`
+
+#![feature(generic_associated_types)]
+
+use std::future::Future;
+
+trait Client {
+    type Connecting<'a>: Future + Send
+    where
+        Self: 'a;
+
+    fn connect(&'_ self) -> Self::Connecting<'_>;
+}
+
+fn call_connect<C>(c: &'_ C) -> impl '_ + Future + Send
+//~^ ERROR the parameter
+//~| ERROR the parameter
+where
+    C: Client + Send + Sync,
+{
+    async move { c.connect().await }
+}
+
+fn main() {}
diff --git a/src/test/ui/generic-associated-types/issue-92096.stderr b/src/test/ui/generic-associated-types/issue-92096.stderr
new file mode 100644
index 00000000000..a897ba5b966
--- /dev/null
+++ b/src/test/ui/generic-associated-types/issue-92096.stderr
@@ -0,0 +1,18 @@
+error[E0311]: the parameter type `C` may not live long enough
+  --> $DIR/issue-92096.rs:18:33
+   |
+LL | fn call_connect<C>(c: &'_ C) -> impl '_ + Future + Send
+   |                 -               ^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `C` will meet its required lifetime bounds
+   |                 |
+   |                 help: consider adding an explicit lifetime bound...: `C: 'a`
+
+error[E0311]: the parameter type `C` may not live long enough
+  --> $DIR/issue-92096.rs:18:33
+   |
+LL | fn call_connect<C>(c: &'_ C) -> impl '_ + Future + Send
+   |                 -               ^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `C` will meet its required lifetime bounds
+   |                 |
+   |                 help: consider adding an explicit lifetime bound...: `C: 'a`
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/generic-associated-types/issue-92280.rs b/src/test/ui/generic-associated-types/issue-92280.rs
new file mode 100644
index 00000000000..db26493ecad
--- /dev/null
+++ b/src/test/ui/generic-associated-types/issue-92280.rs
@@ -0,0 +1,26 @@
+// check-pass
+
+#![feature(generic_associated_types)]
+#![allow(non_camel_case_types)]
+
+trait HasAssoc {
+    type Assoc;
+}
+
+trait Iterate<S: HasAssoc> {
+    type Iter<'a>
+    where
+        Self: 'a;
+}
+
+struct KeySegment_Broken<T> {
+    key: T,
+}
+impl<S: HasAssoc> Iterate<S> for KeySegment_Broken<S::Assoc> {
+    type Iter<'a>
+    where
+        Self: 'a,
+    = ();
+}
+
+fn main() {}