]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr
Ignore i586-unknown-linux-gnu and i586-unknown-musl in tests
[rust.git] / src / test / ui / impl-trait / must_outlive_least_region_or_bound.stderr
1 error: cannot infer an appropriate lifetime
2   --> $DIR/must_outlive_least_region_or_bound.rs:3:35
3    |
4 LL | fn elided(x: &i32) -> impl Copy { x }
5    |                       ---------   ^ ...but this borrow...
6    |                       |
7    |                       this return type evaluates to the `'static` lifetime...
8    |
9 note: ...can't outlive the anonymous lifetime #1 defined on the function body at 3:1
10   --> $DIR/must_outlive_least_region_or_bound.rs:3:1
11    |
12 LL | fn elided(x: &i32) -> impl Copy { x }
13    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14 help: you can add a constraint to the return type to make it last less than `'static` and match the anonymous lifetime #1 defined on the function body at 3:1
15    |
16 LL | fn elided(x: &i32) -> impl Copy + '_ { x }
17    |                       ^^^^^^^^^^^^^^
18
19 error: cannot infer an appropriate lifetime
20   --> $DIR/must_outlive_least_region_or_bound.rs:6:44
21    |
22 LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x }
23    |                                ---------   ^ ...but this borrow...
24    |                                |
25    |                                this return type evaluates to the `'static` lifetime...
26    |
27 note: ...can't outlive the lifetime `'a` as defined on the function body at 6:13
28   --> $DIR/must_outlive_least_region_or_bound.rs:6:13
29    |
30 LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x }
31    |             ^^
32 help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime `'a` as defined on the function body at 6:13
33    |
34 LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x }
35    |                                ^^^^^^^^^^^^^^
36
37 error: cannot infer an appropriate lifetime
38   --> $DIR/must_outlive_least_region_or_bound.rs:12:69
39    |
40 LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
41    |                                  --------------------------------   ^ ...but this borrow...
42    |                                  |
43    |                                  this return type evaluates to the `'static` lifetime...
44    |
45 note: ...can't outlive the lifetime `'a` as defined on the function body at 12:15
46   --> $DIR/must_outlive_least_region_or_bound.rs:12:15
47    |
48 LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
49    |               ^^
50 help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime `'a` as defined on the function body at 12:15
51    |
52 LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static + 'a { x }
53    |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
54
55 error[E0623]: lifetime mismatch
56   --> $DIR/must_outlive_least_region_or_bound.rs:17:61
57    |
58 LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) {
59    |                                                 -------     ^^^^^^^^^^^^^^^^
60    |                                                 |           |
61    |                                                 |           ...but data from `y` is returned here
62    |                                                 this parameter and the return type are declared with different lifetimes...
63
64 error[E0310]: the parameter type `T` may not live long enough
65   --> $DIR/must_outlive_least_region_or_bound.rs:22:51
66    |
67 LL | fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static {
68    |                                 --                ^^^^^^^^^^^^^^^^^^^^
69    |                                 |
70    |                                 help: consider adding an explicit lifetime bound `T: 'static`...
71    |
72 note: ...so that the type `T` will meet its required lifetime bounds
73   --> $DIR/must_outlive_least_region_or_bound.rs:22:51
74    |
75 LL | fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static {
76    |                                                   ^^^^^^^^^^^^^^^^^^^^
77
78 error: aborting due to 5 previous errors
79
80 Some errors have detailed explanations: E0310, E0623.
81 For more information about an error, try `rustc --explain E0310`.