Skip to content

Commit

Permalink
Add async version of self_lifetime.rs test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Aug 8, 2019
1 parent d9294a2 commit f395787
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/test/ui/self/self_lifetime-async.nll.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0106]: missing lifetime specifier
--> $DIR/self_lifetime-async.rs:9:44
|
LL | async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 }
| ^
|
= note: return-position elided lifetimes require exactly one input-position elided lifetime, found none.

error: aborting due to previous error

For more information about this error, try `rustc --explain E0106`.
20 changes: 20 additions & 0 deletions src/test/ui/self/self_lifetime-async.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// FIXME: Investigate why `self_lifetime.rs` is check-pass but this isn't.

// edition:2018

#![feature(async_await)]

struct Foo<'a>(&'a ());
impl<'a> Foo<'a> {
async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 }
//~^ ERROR missing lifetime specifier
//~| ERROR cannot infer an appropriate lifetime
}

type Alias = Foo<'static>;
impl Alias {
async fn bar<'a>(self: &Alias, arg: &'a ()) -> &() { arg }
//~^ ERROR lifetime mismatch
}

fn main() {}
39 changes: 39 additions & 0 deletions src/test/ui/self/self_lifetime-async.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
error[E0106]: missing lifetime specifier
--> $DIR/self_lifetime-async.rs:9:44
|
LL | async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 }
| ^
|
= note: return-position elided lifetimes require exactly one input-position elided lifetime, found none.

error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> $DIR/self_lifetime-async.rs:9:22
|
LL | async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 }
| ^^^^
|
note: first, the lifetime cannot outlive the lifetime 'a as defined on the impl at 8:6...
--> $DIR/self_lifetime-async.rs:8:6
|
LL | impl<'a> Foo<'a> {
| ^^
= note: ...so that the expression is assignable:
expected &Foo<'_>
found &'b Foo<'a>
= note: but, the lifetime must be valid for the static lifetime...
= note: ...so that the types are compatible:
expected &()
found &'static ()

error[E0623]: lifetime mismatch
--> $DIR/self_lifetime-async.rs:16:52
|
LL | async fn bar<'a>(self: &Alias, arg: &'a ()) -> &() { arg }
| ------ ^^^
| | |
| | ...but data from `arg` is returned here
| this parameter and the return type are declared with different lifetimes...

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0106`.

0 comments on commit f395787

Please sign in to comment.