1 error[E0759]: 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 | ---- ^ ...is captured here...
7 | this data with an anonymous lifetime `'_`...
9 note: ...and is required to live as long as `'static` here
10 --> $DIR/must_outlive_least_region_or_bound.rs:3:23
12 LL | fn elided(x: &i32) -> impl Copy { x }
14 help: to declare that the `impl Trait` captures data from argument `x`, you can add an explicit `'_` lifetime bound
16 LL | fn elided(x: &i32) -> impl Copy + '_ { x }
19 error[E0759]: 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 | ------- ^ ...is captured here...
25 | this data with lifetime `'a`...
27 note: ...and is required to live as long as `'static` here
28 --> $DIR/must_outlive_least_region_or_bound.rs:6:32
30 LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x }
32 help: to declare that the `impl Trait` captures data from argument `x`, you can add an explicit `'a` lifetime bound
34 LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x }
37 error[E0759]: cannot infer an appropriate lifetime
38 --> $DIR/must_outlive_least_region_or_bound.rs:9:46
40 LL | fn elided2(x: &i32) -> impl Copy + 'static { x }
41 | ---- ^ ...is captured here...
43 | this data with an anonymous lifetime `'_`...
45 note: ...and is required to live as long as `'static` here
46 --> $DIR/must_outlive_least_region_or_bound.rs:9:24
48 LL | fn elided2(x: &i32) -> impl Copy + 'static { x }
50 help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x`
52 LL | fn elided2(x: &i32) -> impl Copy + '_ { x }
54 help: alternatively, add an explicit `'static` bound to this reference
56 LL | fn elided2(x: &'static i32) -> impl Copy + 'static { x }
59 error[E0759]: cannot infer an appropriate lifetime
60 --> $DIR/must_outlive_least_region_or_bound.rs:12:55
62 LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x }
63 | ------- ^ ...is captured here...
65 | this data with lifetime `'a`...
67 note: ...and is required to live as long as `'static` here
68 --> $DIR/must_outlive_least_region_or_bound.rs:12:33
70 LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x }
72 help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x`
74 LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'a { x }
76 help: alternatively, add an explicit `'static` bound to this reference
78 LL | fn explicit2<'a>(x: &'static i32) -> impl Copy + 'static { x }
81 error[E0621]: explicit lifetime required in the type of `x`
82 --> $DIR/must_outlive_least_region_or_bound.rs:15:24
84 LL | fn foo<'a>(x: &i32) -> impl Copy + 'a { x }
85 | ---- ^^^^^^^^^^^^^^ lifetime `'a` required
87 | help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
89 error[E0759]: cannot infer an appropriate lifetime
90 --> $DIR/must_outlive_least_region_or_bound.rs:33:69
92 LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
93 | ------- this data with lifetime `'a`... ^ ...is captured here...
95 note: ...and is required to live as long as `'static` here
96 --> $DIR/must_outlive_least_region_or_bound.rs:33:34
98 LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
99 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
100 help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x`
102 LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'a { x }
104 help: alternatively, add an explicit `'static` bound to this reference
106 LL | fn with_bound<'a>(x: &'static i32) -> impl LifetimeTrait<'a> + 'static { x }
109 error[E0623]: lifetime mismatch
110 --> $DIR/must_outlive_least_region_or_bound.rs:38:61
112 LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) {
113 | ------- ^^^^^^^^^^^^^^^^
115 | | ...but data from `y` is returned here
116 | this parameter and the return type are declared with different lifetimes...
118 error[E0310]: the parameter type `T` may not live long enough
119 --> $DIR/must_outlive_least_region_or_bound.rs:43:51
121 LL | fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static {
122 | -- ^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
124 | help: consider adding an explicit lifetime bound...: `T: 'static +`
126 error[E0759]: cannot infer an appropriate lifetime
127 --> $DIR/must_outlive_least_region_or_bound.rs:18:50
129 LL | fn elided3(x: &i32) -> Box<dyn Debug> { Box::new(x) }
130 | ---- ^ ...is captured here, requiring it to live as long as `'static`
132 | this data with an anonymous lifetime `'_`...
134 help: to declare that the trait object captures data from argument `x`, you can add an explicit `'_` lifetime bound
136 LL | fn elided3(x: &i32) -> Box<dyn Debug + '_> { Box::new(x) }
139 error[E0759]: cannot infer an appropriate lifetime
140 --> $DIR/must_outlive_least_region_or_bound.rs:21:59
142 LL | fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug> { Box::new(x) }
143 | ------- ^ ...is captured here, requiring it to live as long as `'static`
145 | this data with lifetime `'a`...
147 help: to declare that the trait object captures data from argument `x`, you can add an explicit `'a` lifetime bound
149 LL | fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug + 'a> { Box::new(x) }
152 error[E0759]: cannot infer an appropriate lifetime
153 --> $DIR/must_outlive_least_region_or_bound.rs:24:60
155 LL | fn elided4(x: &i32) -> Box<dyn Debug + 'static> { Box::new(x) }
156 | ---- ^ ...is captured here, requiring it to live as long as `'static`
158 | this data with an anonymous lifetime `'_`...
160 help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x`
162 LL | fn elided4(x: &i32) -> Box<dyn Debug + '_> { Box::new(x) }
164 help: alternatively, add an explicit `'static` bound to this reference
166 LL | fn elided4(x: &'static i32) -> Box<dyn Debug + 'static> { Box::new(x) }
169 error[E0759]: cannot infer an appropriate lifetime
170 --> $DIR/must_outlive_least_region_or_bound.rs:27:69
172 LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'static> { Box::new(x) }
173 | ------- this data with lifetime `'a`... ^ ...is captured here, requiring it to live as long as `'static`
175 help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x`
177 LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'a> { Box::new(x) }
179 help: alternatively, add an explicit `'static` bound to this reference
181 LL | fn explicit4<'a>(x: &'static i32) -> Box<dyn Debug + 'static> { Box::new(x) }
184 error: aborting due to 12 previous errors
186 Some errors have detailed explanations: E0310, E0621, E0623, E0759.
187 For more information about an error, try `rustc --explain E0310`.