Skip to content

Commit f395787

Browse files
committed
Add async version of self_lifetime.rs test.
1 parent d9294a2 commit f395787

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

Diff for: src/test/ui/self/self_lifetime-async.nll.stderr

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0106]: missing lifetime specifier
2+
--> $DIR/self_lifetime-async.rs:9:44
3+
|
4+
LL | async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 }
5+
| ^
6+
|
7+
= note: return-position elided lifetimes require exactly one input-position elided lifetime, found none.
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0106`.

Diff for: src/test/ui/self/self_lifetime-async.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// FIXME: Investigate why `self_lifetime.rs` is check-pass but this isn't.
2+
3+
// edition:2018
4+
5+
#![feature(async_await)]
6+
7+
struct Foo<'a>(&'a ());
8+
impl<'a> Foo<'a> {
9+
async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 }
10+
//~^ ERROR missing lifetime specifier
11+
//~| ERROR cannot infer an appropriate lifetime
12+
}
13+
14+
type Alias = Foo<'static>;
15+
impl Alias {
16+
async fn bar<'a>(self: &Alias, arg: &'a ()) -> &() { arg }
17+
//~^ ERROR lifetime mismatch
18+
}
19+
20+
fn main() {}

Diff for: src/test/ui/self/self_lifetime-async.stderr

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
error[E0106]: missing lifetime specifier
2+
--> $DIR/self_lifetime-async.rs:9:44
3+
|
4+
LL | async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 }
5+
| ^
6+
|
7+
= note: return-position elided lifetimes require exactly one input-position elided lifetime, found none.
8+
9+
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
10+
--> $DIR/self_lifetime-async.rs:9:22
11+
|
12+
LL | async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 }
13+
| ^^^^
14+
|
15+
note: first, the lifetime cannot outlive the lifetime 'a as defined on the impl at 8:6...
16+
--> $DIR/self_lifetime-async.rs:8:6
17+
|
18+
LL | impl<'a> Foo<'a> {
19+
| ^^
20+
= note: ...so that the expression is assignable:
21+
expected &Foo<'_>
22+
found &'b Foo<'a>
23+
= note: but, the lifetime must be valid for the static lifetime...
24+
= note: ...so that the types are compatible:
25+
expected &()
26+
found &'static ()
27+
28+
error[E0623]: lifetime mismatch
29+
--> $DIR/self_lifetime-async.rs:16:52
30+
|
31+
LL | async fn bar<'a>(self: &Alias, arg: &'a ()) -> &() { arg }
32+
| ------ ^^^
33+
| | |
34+
| | ...but data from `arg` is returned here
35+
| this parameter and the return type are declared with different lifetimes...
36+
37+
error: aborting due to 3 previous errors
38+
39+
For more information about this error, try `rustc --explain E0106`.

0 commit comments

Comments
 (0)