about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorBryan Garza <1396101+bryangarza@users.noreply.github.com>2022-10-07 16:08:56 +0000
committerBryan Garza <1396101+bryangarza@users.noreply.github.com>2022-10-27 22:58:54 +0000
commit11b1439380d2e7e915207cb708e78a9060af82b8 (patch)
treecf690ca9131665f06ea5db1660d2ab9d73ebadfc /src/test
parent8a0ebca97eabaed14a36d90aa25327dcec2fa8b1 (diff)
Update tests based on feedback
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/async-await/in-trait/async-associated-types.rs4
-rw-r--r--src/test/ui/async-await/in-trait/async-associated-types.stderr16
-rw-r--r--src/test/ui/async-await/in-trait/async-example.rs17
-rw-r--r--src/test/ui/async-await/in-trait/async-generics-and-bounds.rs4
-rw-r--r--src/test/ui/async-await/in-trait/async-generics-and-bounds.stderr12
-rw-r--r--src/test/ui/async-await/in-trait/async-generics.rs4
-rw-r--r--src/test/ui/async-await/in-trait/async-generics.stderr12
-rw-r--r--src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.rs4
-rw-r--r--src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.stderr4
-rw-r--r--src/test/ui/async-await/in-trait/async-lifetimes.rs4
10 files changed, 48 insertions, 33 deletions
diff --git a/src/test/ui/async-await/in-trait/async-associated-types.rs b/src/test/ui/async-await/in-trait/async-associated-types.rs
index 8f679190d7a..a6f928f3b1b 100644
--- a/src/test/ui/async-await/in-trait/async-associated-types.rs
+++ b/src/test/ui/async-await/in-trait/async-associated-types.rs
@@ -1,3 +1,5 @@
+// check-fail
+// known-bug: #102682
 // edition: 2021
 
 #![feature(async_fn_in_trait)]
@@ -18,7 +20,5 @@ impl<'a, 'b, T: Debug + Sized + 'b, U: 'a> MyTrait<'a, 'b, T> for U {
         (self, key)
     }
 }
-//~^^^^ ERROR cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
-//~| ERROR cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements
 
 fn main() {}
diff --git a/src/test/ui/async-await/in-trait/async-associated-types.stderr b/src/test/ui/async-await/in-trait/async-associated-types.stderr
index c1c66f9023b..0985150eee0 100644
--- a/src/test/ui/async-await/in-trait/async-associated-types.stderr
+++ b/src/test/ui/async-await/in-trait/async-associated-types.stderr
@@ -1,16 +1,16 @@
 error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
-  --> $DIR/async-associated-types.rs:17:43
+  --> $DIR/async-associated-types.rs:19:43
    |
 LL |     async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
    |                                           ^^^^^^^^^^^^^^
    |
 note: first, the lifetime cannot outlive the lifetime `'a` as defined here...
-  --> $DIR/async-associated-types.rs:14:6
+  --> $DIR/async-associated-types.rs:16:6
    |
 LL | impl<'a, 'b, T: Debug + Sized + 'b, U: 'a> MyTrait<'a, 'b, T> for U {
    |      ^^
 note: ...so that the types are compatible
-  --> $DIR/async-associated-types.rs:17:43
+  --> $DIR/async-associated-types.rs:19:43
    |
 LL |     async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
    |                                           ^^^^^^^^^^^^^^
@@ -18,7 +18,7 @@ LL |     async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
               found `(&U, &T)`
    = note: but, the lifetime must be valid for the static lifetime...
 note: ...so that the types are compatible
-  --> $DIR/async-associated-types.rs:17:43
+  --> $DIR/async-associated-types.rs:19:43
    |
 LL |     async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
    |                                           ^^^^^^^^^^^^^^
@@ -26,18 +26,18 @@ LL |     async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
               found `MyTrait<'_, '_, T>`
 
 error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements
-  --> $DIR/async-associated-types.rs:17:43
+  --> $DIR/async-associated-types.rs:19:43
    |
 LL |     async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
    |                                           ^^^^^^^^^^^^^^
    |
 note: first, the lifetime cannot outlive the lifetime `'b` as defined here...
-  --> $DIR/async-associated-types.rs:14:10
+  --> $DIR/async-associated-types.rs:16:10
    |
 LL | impl<'a, 'b, T: Debug + Sized + 'b, U: 'a> MyTrait<'a, 'b, T> for U {
    |          ^^
 note: ...so that the types are compatible
-  --> $DIR/async-associated-types.rs:17:43
+  --> $DIR/async-associated-types.rs:19:43
    |
 LL |     async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
    |                                           ^^^^^^^^^^^^^^
@@ -45,7 +45,7 @@ LL |     async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
               found `(&U, &T)`
    = note: but, the lifetime must be valid for the static lifetime...
 note: ...so that the types are compatible
-  --> $DIR/async-associated-types.rs:17:43
+  --> $DIR/async-associated-types.rs:19:43
    |
 LL |     async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
    |                                           ^^^^^^^^^^^^^^
diff --git a/src/test/ui/async-await/in-trait/async-example.rs b/src/test/ui/async-await/in-trait/async-example.rs
index 2c2297c6b58..10387f09f0e 100644
--- a/src/test/ui/async-await/in-trait/async-example.rs
+++ b/src/test/ui/async-await/in-trait/async-example.rs
@@ -6,12 +6,27 @@
 
 trait MyTrait {
     async fn foo(&self) -> i32;
+    async fn bar(&self) -> i32;
 }
 
 impl MyTrait for i32 {
     async fn foo(&self) -> i32 {
         *self
     }
+
+    async fn bar(&self) -> i32 {
+        self.foo().await
+    }
 }
 
-fn main() {}
+fn main() {
+    let x = 5;
+    // Calling from non-async context
+    let _ = x.foo();
+    let _ = x.bar();
+    // Calling from async block in non-async context
+    async {
+        let _ = x.foo();
+        let _ = x.bar();
+    };
+}
diff --git a/src/test/ui/async-await/in-trait/async-generics-and-bounds.rs b/src/test/ui/async-await/in-trait/async-generics-and-bounds.rs
index d748430c5ee..a73d55adfec 100644
--- a/src/test/ui/async-await/in-trait/async-generics-and-bounds.rs
+++ b/src/test/ui/async-await/in-trait/async-generics-and-bounds.rs
@@ -1,3 +1,5 @@
+// check-fail
+// known-bug: #102682
 // edition: 2021
 
 #![feature(async_fn_in_trait)]
@@ -9,8 +11,6 @@ use std::hash::Hash;
 trait MyTrait<T, U> {
     async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
 }
-//~^^ ERROR the parameter type `U` may not live long enough
-//~| ERROR the parameter type `T` may not live long enough
 
 impl<T, U> MyTrait<T, U> for (T, U) {
     async fn foo(&self) -> &(T, U) {
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 8975ec21a01..5c8d64fc6cb 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
@@ -1,33 +1,33 @@
 error[E0311]: the parameter type `U` may not live long enough
-  --> $DIR/async-generics-and-bounds.rs:10:28
+  --> $DIR/async-generics-and-bounds.rs:12:28
    |
 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...
-  --> $DIR/async-generics-and-bounds.rs:10:18
+  --> $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:10:28
+  --> $DIR/async-generics-and-bounds.rs:12:28
    |
 LL |     async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
    |                            ^^^^^^^
 
 error[E0311]: the parameter type `T` may not live long enough
-  --> $DIR/async-generics-and-bounds.rs:10:28
+  --> $DIR/async-generics-and-bounds.rs:12:28
    |
 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...
-  --> $DIR/async-generics-and-bounds.rs:10:18
+  --> $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:10:28
+  --> $DIR/async-generics-and-bounds.rs:12:28
    |
 LL |     async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
    |                            ^^^^^^^
diff --git a/src/test/ui/async-await/in-trait/async-generics.rs b/src/test/ui/async-await/in-trait/async-generics.rs
index 3e6f70cd49f..67000e5770e 100644
--- a/src/test/ui/async-await/in-trait/async-generics.rs
+++ b/src/test/ui/async-await/in-trait/async-generics.rs
@@ -1,3 +1,5 @@
+// check-fail
+// known-bug: #102682
 // edition: 2021
 
 #![feature(async_fn_in_trait)]
@@ -6,8 +8,6 @@
 trait MyTrait<T, U> {
     async fn foo(&self) -> &(T, U);
 }
-//~^^ ERROR the parameter type `U` may not live long enough
-//~| ERROR the parameter type `T` may not live long enough
 
 impl<T, U> MyTrait<T, U> for (T, U) {
     async fn foo(&self) -> &(T, U) {
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 84c7b309536..6ae73d9e3a6 100644
--- a/src/test/ui/async-await/in-trait/async-generics.stderr
+++ b/src/test/ui/async-await/in-trait/async-generics.stderr
@@ -1,33 +1,33 @@
 error[E0311]: the parameter type `U` may not live long enough
-  --> $DIR/async-generics.rs:7:28
+  --> $DIR/async-generics.rs:9:28
    |
 LL |     async fn foo(&self) -> &(T, U);
    |                            ^^^^^^^
    |
 note: the parameter type `U` must be valid for the anonymous lifetime as defined here...
-  --> $DIR/async-generics.rs:7:18
+  --> $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:7:28
+  --> $DIR/async-generics.rs:9:28
    |
 LL |     async fn foo(&self) -> &(T, U);
    |                            ^^^^^^^
 
 error[E0311]: the parameter type `T` may not live long enough
-  --> $DIR/async-generics.rs:7:28
+  --> $DIR/async-generics.rs:9:28
    |
 LL |     async fn foo(&self) -> &(T, U);
    |                            ^^^^^^^
    |
 note: the parameter type `T` must be valid for the anonymous lifetime as defined here...
-  --> $DIR/async-generics.rs:7:18
+  --> $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:7:28
+  --> $DIR/async-generics.rs:9:28
    |
 LL |     async fn foo(&self) -> &(T, U);
    |                            ^^^^^^^
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 6a2276c96c8..3f7448cecd1 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,3 +1,5 @@
+// check-fail
+// known-bug: #102682
 // edition: 2021
 
 #![feature(async_fn_in_trait)]
@@ -8,8 +10,6 @@ use std::fmt::Debug;
 trait MyTrait<'a, 'b, T> {
     async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T) where T: Debug + Sized;
 }
-//~^^ ERROR  the parameter type `Self` may not live long enough
-//~| ERROR the parameter type `T` may not live long enough
 
 impl<'a, 'b, T, U> MyTrait<'a, 'b, T> for U {
     async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
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
index d74f80917a4..0f024202743 100644
--- 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
@@ -1,5 +1,5 @@
 error[E0309]: the parameter type `Self` may not live long enough
-  --> $DIR/async-lifetimes-and-bounds.rs:9:43
+  --> $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;
    |                                           ^^^^^^^^^^^^^^^^^
@@ -8,7 +8,7 @@ LL |     async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T) where T: Debug
    = 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:9:43
+  --> $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
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 1032a343547..5dc1672da68 100644
--- a/src/test/ui/async-await/in-trait/async-lifetimes.rs
+++ b/src/test/ui/async-await/in-trait/async-lifetimes.rs
@@ -5,9 +5,9 @@
 
 trait MyTrait<'a, 'b, T> {
     async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T);
+    //~^ ERROR the parameter type `Self` may not live long enough
+    //~| ERROR the parameter type `T` may not live long enough
 }
-//~^^ ERROR the parameter type `Self` may not live long enough
-//~| ERROR the parameter type `T` may not live long enough
 
 impl<'a, 'b, T, U> MyTrait<'a, 'b, T> for U {
     async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {