about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2020-08-23 21:51:32 -0700
committerEsteban Küber <esteban@kuber.com.ar>2020-08-23 21:51:32 -0700
commit35e166e5d28b211c4b69fe9ae7c0aa970e71e321 (patch)
treecf9e5c8d86dc2c6676e5f69047f5c6331cf8adfe /src/test
parent663d2f5cd3163f17eddb74ee1e028d542255f21a (diff)
downloadrust-35e166e5d28b211c4b69fe9ae7c0aa970e71e321.tar.gz
rust-35e166e5d28b211c4b69fe9ae7c0aa970e71e321.zip
Account for async functions when suggesting new named lifetime
Fix #75850.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/regions/regions-name-undeclared.rs8
-rw-r--r--src/test/ui/regions/regions-name-undeclared.stderr40
2 files changed, 36 insertions, 12 deletions
diff --git a/src/test/ui/regions/regions-name-undeclared.rs b/src/test/ui/regions/regions-name-undeclared.rs
index 044c6889772..b8f50a40c45 100644
--- a/src/test/ui/regions/regions-name-undeclared.rs
+++ b/src/test/ui/regions/regions-name-undeclared.rs
@@ -1,3 +1,4 @@
+// edition:2018
 // Check that lifetime resolver enforces the lifetime name scoping
 // rules correctly in various scenarios.
 
@@ -47,4 +48,11 @@ fn fn_types(a: &'a isize, //~ ERROR undeclared lifetime
 {
 }
 
+struct Bug {}
+impl Bug {
+    async fn buggy(&self) -> &'a str { //~ ERROR use of undeclared lifetime name `'a`
+        todo!()
+    }
+}
+
 pub fn main() {}
diff --git a/src/test/ui/regions/regions-name-undeclared.stderr b/src/test/ui/regions/regions-name-undeclared.stderr
index 57d39d59c8b..ad0e7bd5afb 100644
--- a/src/test/ui/regions/regions-name-undeclared.stderr
+++ b/src/test/ui/regions/regions-name-undeclared.stderr
@@ -1,5 +1,5 @@
 error[E0261]: use of undeclared lifetime name `'b`
-  --> $DIR/regions-name-undeclared.rs:15:24
+  --> $DIR/regions-name-undeclared.rs:16:24
    |
 LL |     fn m4(&self, arg: &'b isize) { }
    |                        ^^ undeclared lifetime
@@ -15,7 +15,7 @@ LL |     fn m4<'b>(&self, arg: &'b isize) { }
    |          ^^^^
 
 error[E0261]: use of undeclared lifetime name `'b`
-  --> $DIR/regions-name-undeclared.rs:16:12
+  --> $DIR/regions-name-undeclared.rs:17:12
    |
 LL |     fn m5(&'b self) { }
    |            ^^ undeclared lifetime
@@ -31,7 +31,7 @@ LL |     fn m5<'b>(&'b self) { }
    |          ^^^^
 
 error[E0261]: use of undeclared lifetime name `'b`
-  --> $DIR/regions-name-undeclared.rs:17:27
+  --> $DIR/regions-name-undeclared.rs:18:27
    |
 LL |     fn m6(&self, arg: Foo<'b>) { }
    |                           ^^ undeclared lifetime
@@ -47,7 +47,7 @@ LL |     fn m6<'b>(&self, arg: Foo<'b>) { }
    |          ^^^^
 
 error[E0261]: use of undeclared lifetime name `'a`
-  --> $DIR/regions-name-undeclared.rs:25:22
+  --> $DIR/regions-name-undeclared.rs:26:22
    |
 LL |     type X = Option<&'a isize>;
    |           -          ^^ undeclared lifetime
@@ -57,7 +57,7 @@ LL |     type X = Option<&'a isize>;
    = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
 
 error[E0261]: use of undeclared lifetime name `'a`
-  --> $DIR/regions-name-undeclared.rs:27:13
+  --> $DIR/regions-name-undeclared.rs:28:13
    |
 LL |     enum E {
    |           - help: consider introducing lifetime `'a` here: `<'a>`
@@ -67,7 +67,7 @@ LL |         E1(&'a isize)
    = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
 
 error[E0261]: use of undeclared lifetime name `'a`
-  --> $DIR/regions-name-undeclared.rs:30:13
+  --> $DIR/regions-name-undeclared.rs:31:13
    |
 LL |     struct S {
    |             - help: consider introducing lifetime `'a` here: `<'a>`
@@ -77,7 +77,7 @@ LL |         f: &'a isize
    = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
 
 error[E0261]: use of undeclared lifetime name `'a`
-  --> $DIR/regions-name-undeclared.rs:32:14
+  --> $DIR/regions-name-undeclared.rs:33:14
    |
 LL |     fn f(a: &'a isize) { }
    |         -    ^^ undeclared lifetime
@@ -87,7 +87,7 @@ LL |     fn f(a: &'a isize) { }
    = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
 
 error[E0261]: use of undeclared lifetime name `'a`
-  --> $DIR/regions-name-undeclared.rs:40:17
+  --> $DIR/regions-name-undeclared.rs:41:17
    |
 LL | fn fn_types(a: &'a isize,
    |            -    ^^ undeclared lifetime
@@ -97,7 +97,7 @@ LL | fn fn_types(a: &'a isize,
    = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
 
 error[E0261]: use of undeclared lifetime name `'b`
-  --> $DIR/regions-name-undeclared.rs:42:36
+  --> $DIR/regions-name-undeclared.rs:43:36
    |
 LL | ...                   &'b isize,
    |                        ^^ undeclared lifetime
@@ -114,7 +114,7 @@ LL |             b: Box<dyn for<'a, 'b> FnOnce(&'a isize,
    |                              ^^^^
 
 error[E0261]: use of undeclared lifetime name `'b`
-  --> $DIR/regions-name-undeclared.rs:45:36
+  --> $DIR/regions-name-undeclared.rs:46:36
    |
 LL | ...                   &'b isize)>,
    |                        ^^ undeclared lifetime
@@ -131,7 +131,7 @@ LL |             b: Box<dyn for<'a, 'b> FnOnce(&'a isize,
    |                              ^^^^
 
 error[E0261]: use of undeclared lifetime name `'a`
-  --> $DIR/regions-name-undeclared.rs:46:17
+  --> $DIR/regions-name-undeclared.rs:47:17
    |
 LL | fn fn_types(a: &'a isize,
    |            - help: consider introducing lifetime `'a` here: `<'a>`
@@ -141,6 +141,22 @@ LL |             c: &'a isize)
    |
    = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
 
-error: aborting due to 11 previous errors
+error[E0261]: use of undeclared lifetime name `'a`
+  --> $DIR/regions-name-undeclared.rs:53:31
+   |
+LL |     async fn buggy(&self) -> &'a str {
+   |                               ^^ undeclared lifetime
+   |
+   = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
+help: consider introducing lifetime `'a` here
+   |
+LL | impl<'a> Bug {
+   |     ^^^^
+help: consider introducing lifetime `'a` here
+   |
+LL |     async fn buggy<'a>(&self) -> &'a str {
+   |                   ^^^^
+
+error: aborting due to 12 previous errors
 
 For more information about this error, try `rustc --explain E0261`.