1 error: cannot infer an appropriate lifetime
2 --> $DIR/must_outlive_least_region_or_bound.rs:3:35
4 LL | fn elided(x: &i32) -> impl Copy { x }
5 | --------- ^ ...but this borrow...
7 | this return type evaluates to the `'static` lifetime...
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
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
16 LL | fn elided(x: &i32) -> impl Copy + '_ { x }
19 error: cannot infer an appropriate lifetime
20 --> $DIR/must_outlive_least_region_or_bound.rs:6:44
22 LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x }
23 | --------- ^ ...but this borrow...
25 | this return type evaluates to the `'static` lifetime...
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
30 LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x }
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
34 LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x }
37 error: cannot infer an appropriate lifetime
38 --> $DIR/must_outlive_least_region_or_bound.rs:12:69
40 LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
41 | -------------------------------- ^ ...but this borrow...
43 | this return type evaluates to the `'static` lifetime...
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
48 LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
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
52 LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static + 'a { x }
53 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
55 error[E0623]: lifetime mismatch
56 --> $DIR/must_outlive_least_region_or_bound.rs:17:61
58 LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) {
59 | ------- ^^^^^^^^^^^^^^^^
61 | | ...but data from `y` is returned here
62 | this parameter and the return type are declared with different lifetimes...
64 error[E0310]: the parameter type `T` may not live long enough
65 --> $DIR/must_outlive_least_region_or_bound.rs:22:51
67 LL | fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static {
68 | -- ^^^^^^^^^^^^^^^^^^^^
70 | help: consider adding an explicit lifetime bound `T: 'static`...
72 note: ...so that the type `T` will meet its required lifetime bounds
73 --> $DIR/must_outlive_least_region_or_bound.rs:22:51
75 LL | fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static {
76 | ^^^^^^^^^^^^^^^^^^^^
78 error: aborting due to 5 previous errors
80 Some errors have detailed explanations: E0310, E0623.
81 For more information about an error, try `rustc --explain E0310`.