]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr
ca9ca8a9debe2a62dfee8a8b31a77f81506bb096
[rust.git] / src / test / ui / impl-trait / must_outlive_least_region_or_bound.nll.stderr
1 error: lifetime may not live long enough
2   --> $DIR/must_outlive_least_region_or_bound.rs:3:23
3    |
4 LL | fn elided(x: &i32) -> impl Copy { x }
5    |              -        ^^^^^^^^^ opaque type requires that `'1` must outlive `'static`
6    |              |
7    |              let's call the lifetime of this reference `'1`
8    |
9 help: to allow this `impl Trait` to capture borrowed data with lifetime `'1`, add `'_` as a bound
10    |
11 LL | fn elided(x: &i32) -> impl Copy + '_ { x }
12    |                       ^^^^^^^^^^^^^^
13
14 error: lifetime may not live long enough
15   --> $DIR/must_outlive_least_region_or_bound.rs:6:32
16    |
17 LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x }
18    |             --                 ^^^^^^^^^ opaque type requires that `'a` must outlive `'static`
19    |             |
20    |             lifetime `'a` defined here
21    |
22    = help: consider replacing `'a` with `'static`
23 help: to allow this `impl Trait` to capture borrowed data with lifetime `'a`, add `'a` as a bound
24    |
25 LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x }
26    |                                ^^^^^^^^^^^^^^
27
28 error: lifetime may not live long enough
29   --> $DIR/must_outlive_least_region_or_bound.rs:9:46
30    |
31 LL | fn elided2(x: &i32) -> impl Copy + 'static { x }
32    |               -                              ^ returning this value requires that `'1` must outlive `'static`
33    |               |
34    |               let's call the lifetime of this reference `'1`
35    |
36    = help: consider replacing `'1` with `'static`
37
38 error: lifetime may not live long enough
39   --> $DIR/must_outlive_least_region_or_bound.rs:12:55
40    |
41 LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x }
42    |              -- lifetime `'a` defined here            ^ returning this value requires that `'a` must outlive `'static`
43    |
44    = help: consider replacing `'a` with `'static`
45    = help: consider replacing `'a` with `'static`
46
47 error[E0621]: explicit lifetime required in the type of `x`
48   --> $DIR/must_outlive_least_region_or_bound.rs:15:41
49    |
50 LL | fn foo<'a>(x: &i32) -> impl Copy + 'a { x }
51    |               ----                      ^ lifetime `'a` required
52    |               |
53    |               help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
54
55 error: lifetime may not live long enough
56   --> $DIR/must_outlive_least_region_or_bound.rs:33:69
57    |
58 LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
59    |               -- lifetime `'a` defined here                         ^ returning this value requires that `'a` must outlive `'static`
60    |
61    = help: consider replacing `'a` with `'static`
62    = help: consider replacing `'a` with `'static`
63
64 error: lifetime may not live long enough
65   --> $DIR/must_outlive_least_region_or_bound.rs:38:61
66    |
67 LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) {
68    |                          --  -- lifetime `'b` defined here  ^^^^^^^^^^^^^^^^ opaque type requires that `'b` must outlive `'a`
69    |                          |
70    |                          lifetime `'a` defined here
71    |
72    = help: consider adding the following bound: `'b: 'a`
73
74 error[E0310]: the parameter type `T` may not live long enough
75   --> $DIR/must_outlive_least_region_or_bound.rs:43:51
76    |
77 LL | fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static {
78    |                                                   ^^^^^^^^^^^^^^^^^^^^
79    |
80    = help: consider adding an explicit lifetime bound `T: 'static`...
81
82 error: aborting due to 8 previous errors
83
84 Some errors have detailed explanations: E0310, E0621.
85 For more information about an error, try `rustc --explain E0310`.