From f3957876c81ce45c31895316060e23149c6fb964 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 8 Aug 2019 17:08:30 +0200 Subject: [PATCH] Add async version of self_lifetime.rs test. --- .../ui/self/self_lifetime-async.nll.stderr | 11 ++++++ src/test/ui/self/self_lifetime-async.rs | 20 ++++++++++ src/test/ui/self/self_lifetime-async.stderr | 39 +++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 src/test/ui/self/self_lifetime-async.nll.stderr create mode 100644 src/test/ui/self/self_lifetime-async.rs create mode 100644 src/test/ui/self/self_lifetime-async.stderr diff --git a/src/test/ui/self/self_lifetime-async.nll.stderr b/src/test/ui/self/self_lifetime-async.nll.stderr new file mode 100644 index 0000000000000..805d2433f87ac --- /dev/null +++ b/src/test/ui/self/self_lifetime-async.nll.stderr @@ -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`. diff --git a/src/test/ui/self/self_lifetime-async.rs b/src/test/ui/self/self_lifetime-async.rs new file mode 100644 index 0000000000000..71eba01fe1a02 --- /dev/null +++ b/src/test/ui/self/self_lifetime-async.rs @@ -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() {} diff --git a/src/test/ui/self/self_lifetime-async.stderr b/src/test/ui/self/self_lifetime-async.stderr new file mode 100644 index 0000000000000..e3ec1abd44763 --- /dev/null +++ b/src/test/ui/self/self_lifetime-async.stderr @@ -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`.