Skip to content

Commit 11b1439

Browse files
committed
Update tests based on feedback
1 parent 8a0ebca commit 11b1439

10 files changed

+48
-33
lines changed

src/test/ui/async-await/in-trait/async-associated-types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// check-fail
2+
// known-bug: #102682
13
// edition: 2021
24

35
#![feature(async_fn_in_trait)]
@@ -18,7 +20,5 @@ impl<'a, 'b, T: Debug + Sized + 'b, U: 'a> MyTrait<'a, 'b, T> for U {
1820
(self, key)
1921
}
2022
}
21-
//~^^^^ ERROR cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
22-
//~| ERROR cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements
2323

2424
fn main() {}

src/test/ui/async-await/in-trait/async-associated-types.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
2-
--> $DIR/async-associated-types.rs:17:43
2+
--> $DIR/async-associated-types.rs:19:43
33
|
44
LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
55
| ^^^^^^^^^^^^^^
66
|
77
note: first, the lifetime cannot outlive the lifetime `'a` as defined here...
8-
--> $DIR/async-associated-types.rs:14:6
8+
--> $DIR/async-associated-types.rs:16:6
99
|
1010
LL | impl<'a, 'b, T: Debug + Sized + 'b, U: 'a> MyTrait<'a, 'b, T> for U {
1111
| ^^
1212
note: ...so that the types are compatible
13-
--> $DIR/async-associated-types.rs:17:43
13+
--> $DIR/async-associated-types.rs:19:43
1414
|
1515
LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
1616
| ^^^^^^^^^^^^^^
1717
= note: expected `(&'a U, &'b T)`
1818
found `(&U, &T)`
1919
= note: but, the lifetime must be valid for the static lifetime...
2020
note: ...so that the types are compatible
21-
--> $DIR/async-associated-types.rs:17:43
21+
--> $DIR/async-associated-types.rs:19:43
2222
|
2323
LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
2424
| ^^^^^^^^^^^^^^
2525
= note: expected `MyTrait<'static, 'static, T>`
2626
found `MyTrait<'_, '_, T>`
2727

2828
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements
29-
--> $DIR/async-associated-types.rs:17:43
29+
--> $DIR/async-associated-types.rs:19:43
3030
|
3131
LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
3232
| ^^^^^^^^^^^^^^
3333
|
3434
note: first, the lifetime cannot outlive the lifetime `'b` as defined here...
35-
--> $DIR/async-associated-types.rs:14:10
35+
--> $DIR/async-associated-types.rs:16:10
3636
|
3737
LL | impl<'a, 'b, T: Debug + Sized + 'b, U: 'a> MyTrait<'a, 'b, T> for U {
3838
| ^^
3939
note: ...so that the types are compatible
40-
--> $DIR/async-associated-types.rs:17:43
40+
--> $DIR/async-associated-types.rs:19:43
4141
|
4242
LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
4343
| ^^^^^^^^^^^^^^
4444
= note: expected `(&'a U, &'b T)`
4545
found `(&U, &T)`
4646
= note: but, the lifetime must be valid for the static lifetime...
4747
note: ...so that the types are compatible
48-
--> $DIR/async-associated-types.rs:17:43
48+
--> $DIR/async-associated-types.rs:19:43
4949
|
5050
LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
5151
| ^^^^^^^^^^^^^^

src/test/ui/async-await/in-trait/async-example.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,27 @@
66

77
trait MyTrait {
88
async fn foo(&self) -> i32;
9+
async fn bar(&self) -> i32;
910
}
1011

1112
impl MyTrait for i32 {
1213
async fn foo(&self) -> i32 {
1314
*self
1415
}
16+
17+
async fn bar(&self) -> i32 {
18+
self.foo().await
19+
}
1520
}
1621

17-
fn main() {}
22+
fn main() {
23+
let x = 5;
24+
// Calling from non-async context
25+
let _ = x.foo();
26+
let _ = x.bar();
27+
// Calling from async block in non-async context
28+
async {
29+
let _ = x.foo();
30+
let _ = x.bar();
31+
};
32+
}

src/test/ui/async-await/in-trait/async-generics-and-bounds.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// check-fail
2+
// known-bug: #102682
13
// edition: 2021
24

35
#![feature(async_fn_in_trait)]
@@ -9,8 +11,6 @@ use std::hash::Hash;
911
trait MyTrait<T, U> {
1012
async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
1113
}
12-
//~^^ ERROR the parameter type `U` may not live long enough
13-
//~| ERROR the parameter type `T` may not live long enough
1414

1515
impl<T, U> MyTrait<T, U> for (T, U) {
1616
async fn foo(&self) -> &(T, U) {

src/test/ui/async-await/in-trait/async-generics-and-bounds.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
error[E0311]: the parameter type `U` may not live long enough
2-
--> $DIR/async-generics-and-bounds.rs:10:28
2+
--> $DIR/async-generics-and-bounds.rs:12:28
33
|
44
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
55
| ^^^^^^^
66
|
77
note: the parameter type `U` must be valid for the anonymous lifetime as defined here...
8-
--> $DIR/async-generics-and-bounds.rs:10:18
8+
--> $DIR/async-generics-and-bounds.rs:12:18
99
|
1010
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
1111
| ^
1212
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
13-
--> $DIR/async-generics-and-bounds.rs:10:28
13+
--> $DIR/async-generics-and-bounds.rs:12:28
1414
|
1515
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
1616
| ^^^^^^^
1717

1818
error[E0311]: the parameter type `T` may not live long enough
19-
--> $DIR/async-generics-and-bounds.rs:10:28
19+
--> $DIR/async-generics-and-bounds.rs:12:28
2020
|
2121
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
2222
| ^^^^^^^
2323
|
2424
note: the parameter type `T` must be valid for the anonymous lifetime as defined here...
25-
--> $DIR/async-generics-and-bounds.rs:10:18
25+
--> $DIR/async-generics-and-bounds.rs:12:18
2626
|
2727
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
2828
| ^
2929
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
30-
--> $DIR/async-generics-and-bounds.rs:10:28
30+
--> $DIR/async-generics-and-bounds.rs:12:28
3131
|
3232
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
3333
| ^^^^^^^

src/test/ui/async-await/in-trait/async-generics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// check-fail
2+
// known-bug: #102682
13
// edition: 2021
24

35
#![feature(async_fn_in_trait)]
@@ -6,8 +8,6 @@
68
trait MyTrait<T, U> {
79
async fn foo(&self) -> &(T, U);
810
}
9-
//~^^ ERROR the parameter type `U` may not live long enough
10-
//~| ERROR the parameter type `T` may not live long enough
1111

1212
impl<T, U> MyTrait<T, U> for (T, U) {
1313
async fn foo(&self) -> &(T, U) {

src/test/ui/async-await/in-trait/async-generics.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
error[E0311]: the parameter type `U` may not live long enough
2-
--> $DIR/async-generics.rs:7:28
2+
--> $DIR/async-generics.rs:9:28
33
|
44
LL | async fn foo(&self) -> &(T, U);
55
| ^^^^^^^
66
|
77
note: the parameter type `U` must be valid for the anonymous lifetime as defined here...
8-
--> $DIR/async-generics.rs:7:18
8+
--> $DIR/async-generics.rs:9:18
99
|
1010
LL | async fn foo(&self) -> &(T, U);
1111
| ^
1212
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
13-
--> $DIR/async-generics.rs:7:28
13+
--> $DIR/async-generics.rs:9:28
1414
|
1515
LL | async fn foo(&self) -> &(T, U);
1616
| ^^^^^^^
1717

1818
error[E0311]: the parameter type `T` may not live long enough
19-
--> $DIR/async-generics.rs:7:28
19+
--> $DIR/async-generics.rs:9:28
2020
|
2121
LL | async fn foo(&self) -> &(T, U);
2222
| ^^^^^^^
2323
|
2424
note: the parameter type `T` must be valid for the anonymous lifetime as defined here...
25-
--> $DIR/async-generics.rs:7:18
25+
--> $DIR/async-generics.rs:9:18
2626
|
2727
LL | async fn foo(&self) -> &(T, U);
2828
| ^
2929
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
30-
--> $DIR/async-generics.rs:7:28
30+
--> $DIR/async-generics.rs:9:28
3131
|
3232
LL | async fn foo(&self) -> &(T, U);
3333
| ^^^^^^^

src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// check-fail
2+
// known-bug: #102682
13
// edition: 2021
24

35
#![feature(async_fn_in_trait)]
@@ -8,8 +10,6 @@ use std::fmt::Debug;
810
trait MyTrait<'a, 'b, T> {
911
async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T) where T: Debug + Sized;
1012
}
11-
//~^^ ERROR the parameter type `Self` may not live long enough
12-
//~| ERROR the parameter type `T` may not live long enough
1313

1414
impl<'a, 'b, T, U> MyTrait<'a, 'b, T> for U {
1515
async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {

src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0309]: the parameter type `Self` may not live long enough
2-
--> $DIR/async-lifetimes-and-bounds.rs:9:43
2+
--> $DIR/async-lifetimes-and-bounds.rs:11:43
33
|
44
LL | async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T) where T: Debug + Sized;
55
| ^^^^^^^^^^^^^^^^^
@@ -8,7 +8,7 @@ LL | async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T) where T: Debug
88
= note: ...so that the reference type `&'a Self` does not outlive the data it points at
99

1010
error[E0309]: the parameter type `T` may not live long enough
11-
--> $DIR/async-lifetimes-and-bounds.rs:9:43
11+
--> $DIR/async-lifetimes-and-bounds.rs:11:43
1212
|
1313
LL | async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T) where T: Debug + Sized;
1414
| ^^^^^^^^^^^^^^^^^ ...so that the reference type `&'b T` does not outlive the data it points at

src/test/ui/async-await/in-trait/async-lifetimes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
trait MyTrait<'a, 'b, T> {
77
async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T);
8+
//~^ ERROR the parameter type `Self` may not live long enough
9+
//~| ERROR the parameter type `T` may not live long enough
810
}
9-
//~^^ ERROR the parameter type `Self` may not live long enough
10-
//~| ERROR the parameter type `T` may not live long enough
1111

1212
impl<'a, 'b, T, U> MyTrait<'a, 'b, T> for U {
1313
async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {

0 commit comments

Comments
 (0)