Add async version of self_lifetime.rs test.
This commit is contained in:
parent
d9294a284d
commit
f3957876c8
3 changed files with 70 additions and 0 deletions
11
src/test/ui/self/self_lifetime-async.nll.stderr
Normal file
11
src/test/ui/self/self_lifetime-async.nll.stderr
Normal file
|
@ -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
src/test/ui/self/self_lifetime-async.rs
Normal file
20
src/test/ui/self/self_lifetime-async.rs
Normal file
|
@ -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
src/test/ui/self/self_lifetime-async.stderr
Normal file
39
src/test/ui/self/self_lifetime-async.stderr
Normal file
|
@ -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`.
|
Loading…
Add table
Reference in a new issue