about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-12-04 16:25:34 +0100
committerGitHub <noreply@github.com>2022-12-04 16:25:34 +0100
commitd055d6ad5efde23ba14a6c045f29321e3659cb3a (patch)
tree0ed37891766f3fe40e73283ba337da8c465b998b /src/test
parentf3eba2130d5bf82e066da56fbc6ec53beef079de (diff)
parent12473d3f36d4c9214443936be2c81975f24c446a (diff)
downloadrust-d055d6ad5efde23ba14a6c045f29321e3659cb3a.tar.gz
rust-d055d6ad5efde23ba14a6c045f29321e3659cb3a.zip
Rollup merge of #105247 - cjgillot:issue-102682, r=compiler-errors
Use parent function WfCheckingContext to check RPITIT.

WF-check for RPITIT was done in the opaque type's param-env, so it could not benefit from assumed wf types from the function's parameters.

cc `@compiler-errors` since you chose that param-env in fd2766e7fde4

Fixes https://github.com/rust-lang/rust/issues/102682
Fixes https://github.com/rust-lang/rust/issues/104908
Fixes https://github.com/rust-lang/rust/issues/102552
Fixes https://github.com/rust-lang/rust/issues/104529
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/async-await/in-trait/async-generics-and-bounds.stderr8
-rw-r--r--src/test/ui/async-await/in-trait/async-generics.stderr8
-rw-r--r--src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.rs3
-rw-r--r--src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.stderr23
-rw-r--r--src/test/ui/async-await/in-trait/async-lifetimes.rs3
-rw-r--r--src/test/ui/async-await/in-trait/async-lifetimes.stderr23
-rw-r--r--src/test/ui/async-await/in-trait/implied-bounds.rs13
-rw-r--r--src/test/ui/impl-trait/in-trait/where-clause.rs24
8 files changed, 47 insertions, 58 deletions
diff --git a/src/test/ui/async-await/in-trait/async-generics-and-bounds.stderr b/src/test/ui/async-await/in-trait/async-generics-and-bounds.stderr
index 5c8d64fc6cb..f1f0d7e5907 100644
--- a/src/test/ui/async-await/in-trait/async-generics-and-bounds.stderr
+++ b/src/test/ui/async-await/in-trait/async-generics-and-bounds.stderr
@@ -4,11 +4,11 @@ error[E0311]: the parameter type `U` may not live long enough
 LL |     async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
    |                            ^^^^^^^
    |
-note: the parameter type `U` must be valid for the anonymous lifetime as defined here...
+note: the parameter type `U` must be valid for the anonymous lifetime defined here...
   --> $DIR/async-generics-and-bounds.rs:12:18
    |
 LL |     async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
-   |                  ^
+   |                  ^^^^^
 note: ...so that the reference type `&(T, U)` does not outlive the data it points at
   --> $DIR/async-generics-and-bounds.rs:12:28
    |
@@ -21,11 +21,11 @@ error[E0311]: the parameter type `T` may not live long enough
 LL |     async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
    |                            ^^^^^^^
    |
-note: the parameter type `T` must be valid for the anonymous lifetime as defined here...
+note: the parameter type `T` must be valid for the anonymous lifetime defined here...
   --> $DIR/async-generics-and-bounds.rs:12:18
    |
 LL |     async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
-   |                  ^
+   |                  ^^^^^
 note: ...so that the reference type `&(T, U)` does not outlive the data it points at
   --> $DIR/async-generics-and-bounds.rs:12:28
    |
diff --git a/src/test/ui/async-await/in-trait/async-generics.stderr b/src/test/ui/async-await/in-trait/async-generics.stderr
index 6ae73d9e3a6..2f05564564c 100644
--- a/src/test/ui/async-await/in-trait/async-generics.stderr
+++ b/src/test/ui/async-await/in-trait/async-generics.stderr
@@ -4,11 +4,11 @@ error[E0311]: the parameter type `U` may not live long enough
 LL |     async fn foo(&self) -> &(T, U);
    |                            ^^^^^^^
    |
-note: the parameter type `U` must be valid for the anonymous lifetime as defined here...
+note: the parameter type `U` must be valid for the anonymous lifetime defined here...
   --> $DIR/async-generics.rs:9:18
    |
 LL |     async fn foo(&self) -> &(T, U);
-   |                  ^
+   |                  ^^^^^
 note: ...so that the reference type `&(T, U)` does not outlive the data it points at
   --> $DIR/async-generics.rs:9:28
    |
@@ -21,11 +21,11 @@ error[E0311]: the parameter type `T` may not live long enough
 LL |     async fn foo(&self) -> &(T, U);
    |                            ^^^^^^^
    |
-note: the parameter type `T` must be valid for the anonymous lifetime as defined here...
+note: the parameter type `T` must be valid for the anonymous lifetime defined here...
   --> $DIR/async-generics.rs:9:18
    |
 LL |     async fn foo(&self) -> &(T, U);
-   |                  ^
+   |                  ^^^^^
 note: ...so that the reference type `&(T, U)` does not outlive the data it points at
   --> $DIR/async-generics.rs:9:28
    |
diff --git a/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.rs b/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.rs
index 3f7448cecd1..d5481d277e4 100644
--- a/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.rs
+++ b/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.rs
@@ -1,5 +1,4 @@
-// check-fail
-// known-bug: #102682
+// check-pass
 // edition: 2021
 
 #![feature(async_fn_in_trait)]
diff --git a/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.stderr b/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.stderr
deleted file mode 100644
index 0f024202743..00000000000
--- a/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.stderr
+++ /dev/null
@@ -1,23 +0,0 @@
-error[E0309]: the parameter type `Self` may not live long enough
-  --> $DIR/async-lifetimes-and-bounds.rs:11:43
-   |
-LL |     async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T) where T: Debug + Sized;
-   |                                           ^^^^^^^^^^^^^^^^^
-   |
-   = help: consider adding an explicit lifetime bound `Self: 'a`...
-   = note: ...so that the reference type `&'a Self` does not outlive the data it points at
-
-error[E0309]: the parameter type `T` may not live long enough
-  --> $DIR/async-lifetimes-and-bounds.rs:11:43
-   |
-LL |     async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T) where T: Debug + Sized;
-   |                                           ^^^^^^^^^^^^^^^^^ ...so that the reference type `&'b T` does not outlive the data it points at
-   |
-help: consider adding an explicit lifetime bound...
-   |
-LL | trait MyTrait<'a, 'b, T: 'b> {
-   |                        ++++
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0309`.
diff --git a/src/test/ui/async-await/in-trait/async-lifetimes.rs b/src/test/ui/async-await/in-trait/async-lifetimes.rs
index acbac471cf7..f298e45d239 100644
--- a/src/test/ui/async-await/in-trait/async-lifetimes.rs
+++ b/src/test/ui/async-await/in-trait/async-lifetimes.rs
@@ -1,5 +1,4 @@
-// check-fail
-// known-bug: #102682
+// check-pass
 // edition: 2021
 
 #![feature(async_fn_in_trait)]
diff --git a/src/test/ui/async-await/in-trait/async-lifetimes.stderr b/src/test/ui/async-await/in-trait/async-lifetimes.stderr
deleted file mode 100644
index 9a7d294bb17..00000000000
--- a/src/test/ui/async-await/in-trait/async-lifetimes.stderr
+++ /dev/null
@@ -1,23 +0,0 @@
-error[E0309]: the parameter type `Self` may not live long enough
-  --> $DIR/async-lifetimes.rs:9:43
-   |
-LL |     async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T);
-   |                                           ^^^^^^^^^^^^^^^^^
-   |
-   = help: consider adding an explicit lifetime bound `Self: 'a`...
-   = note: ...so that the reference type `&'a Self` does not outlive the data it points at
-
-error[E0309]: the parameter type `T` may not live long enough
-  --> $DIR/async-lifetimes.rs:9:43
-   |
-LL |     async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T);
-   |                                           ^^^^^^^^^^^^^^^^^ ...so that the reference type `&'b T` does not outlive the data it points at
-   |
-help: consider adding an explicit lifetime bound...
-   |
-LL | trait MyTrait<'a, 'b, T: 'b> {
-   |                        ++++
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0309`.
diff --git a/src/test/ui/async-await/in-trait/implied-bounds.rs b/src/test/ui/async-await/in-trait/implied-bounds.rs
new file mode 100644
index 00000000000..52bceb3cc5c
--- /dev/null
+++ b/src/test/ui/async-await/in-trait/implied-bounds.rs
@@ -0,0 +1,13 @@
+// check-pass
+// edition: 2021
+
+#![feature(async_fn_in_trait)]
+#![allow(incomplete_features)]
+
+trait TcpStack {
+    type Connection<'a>: Sized where Self: 'a;
+    fn connect<'a>(&'a self) -> Self::Connection<'a>;
+    async fn async_connect<'a>(&'a self) -> Self::Connection<'a>;
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/in-trait/where-clause.rs b/src/test/ui/impl-trait/in-trait/where-clause.rs
new file mode 100644
index 00000000000..87bac519cf3
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/where-clause.rs
@@ -0,0 +1,24 @@
+// check-pass
+// edition: 2021
+
+#![feature(return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+use std::fmt::Debug;
+
+trait Foo<Item> {
+    fn foo<'a>(&'a self) -> impl Debug
+    where
+        Item: 'a;
+}
+
+impl<Item, D: Debug + Clone> Foo<Item> for D {
+    fn foo<'a>(&'a self) -> impl Debug
+    where
+        Item: 'a,
+    {
+        self.clone()
+    }
+}
+
+fn main() {}