File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ use async_trait:: async_trait;
2
+
3
+ #[ async_trait]
4
+ trait Foo {
5
+ async fn bar ( & self , x : & str , y : & ' _ str ) -> & ' static str ;
6
+ }
7
+
8
+ struct S ( String ) ;
9
+
10
+ #[ async_trait]
11
+ impl Foo for S {
12
+ async fn bar ( & self , x : & str , y : & ' _ str ) -> & ' static str {
13
+ if false {
14
+ & self . 0
15
+ } else if false {
16
+ x
17
+ } else {
18
+ y
19
+ }
20
+ }
21
+ }
22
+
23
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error: lifetime may not live long enough
2
+ --> tests/ui/lifetime-defined-here.rs:12:49
3
+ |
4
+ 12 | async fn bar(&self, x: &str, y: &'_ str) -> &'static str {
5
+ | ----- lifetime `'life0` defined here ^^^^^^^^^^^^ type annotation requires that `'life0` must outlive `'static`
6
+
7
+ error: lifetime may not live long enough
8
+ --> tests/ui/lifetime-defined-here.rs:12:49
9
+ |
10
+ 12 | async fn bar(&self, x: &str, y: &'_ str) -> &'static str {
11
+ | ----- lifetime `'life1` defined here ^^^^^^^^^^^^ type annotation requires that `'life1` must outlive `'static`
12
+
13
+ error: lifetime may not live long enough
14
+ --> tests/ui/lifetime-defined-here.rs:12:49
15
+ |
16
+ 12 | async fn bar(&self, x: &str, y: &'_ str) -> &'static str {
17
+ | -- ^^^^^^^^^^^^ type annotation requires that `'life2` must outlive `'static`
18
+ | |
19
+ | lifetime `'life2` defined here
20
+
21
+ help: the following changes may resolve your lifetime errors
22
+ |
23
+ = help: replace `'life0` with `'static`
24
+ = help: replace `'life1` with `'static`
25
+ = help: replace `'life2` with `'static`
You can’t perform that action at this time.
0 commit comments