forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add async version of self_lifetime.rs test.
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |