1 error[E0700]: hidden type for `impl Copy` captures lifetime that does not appear in bounds
2 --> $DIR/must_outlive_least_region_or_bound.rs:3:35
4 LL | fn elided(x: &i32) -> impl Copy { x }
7 | hidden type `&i32` captures the anonymous lifetime defined here
9 help: to declare that `impl Copy` captures `'_`, you can add an explicit `'_` lifetime bound
11 LL | fn elided(x: &i32) -> impl Copy + '_ { x }
14 error[E0700]: hidden type for `impl Copy` captures lifetime that does not appear in bounds
15 --> $DIR/must_outlive_least_region_or_bound.rs:6:44
17 LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x }
20 | hidden type `&'a i32` captures the lifetime `'a` as defined here
22 help: to declare that `impl Copy` captures `'a`, you can add an explicit `'a` lifetime bound
24 LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x }
27 error: lifetime may not live long enough
28 --> $DIR/must_outlive_least_region_or_bound.rs:9:46
30 LL | fn elided2(x: &i32) -> impl Copy + 'static { x }
31 | - ^ returning this value requires that `'1` must outlive `'static`
33 | let's call the lifetime of this reference `'1`
35 help: consider changing `impl Copy + 'static`'s explicit `'static` bound to the lifetime of argument `x`
37 LL | fn elided2(x: &i32) -> impl Copy + '_ { x }
39 help: alternatively, add an explicit `'static` bound to this reference
41 LL | fn elided2(x: &'static i32) -> impl Copy + 'static { x }
44 error: lifetime may not live long enough
45 --> $DIR/must_outlive_least_region_or_bound.rs:12:55
47 LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x }
48 | -- lifetime `'a` defined here ^ returning this value requires that `'a` must outlive `'static`
50 help: consider changing `impl Copy + 'static`'s explicit `'static` bound to the lifetime of argument `x`
52 LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'a { x }
54 help: alternatively, add an explicit `'static` bound to this reference
56 LL | fn explicit2<'a>(x: &'static i32) -> impl Copy + 'static { x }
59 error[E0621]: explicit lifetime required in the type of `x`
60 --> $DIR/must_outlive_least_region_or_bound.rs:15:41
62 LL | fn foo<'a>(x: &i32) -> impl Copy + 'a { x }
63 | ---- ^ lifetime `'a` required
65 | help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
67 error: lifetime may not live long enough
68 --> $DIR/must_outlive_least_region_or_bound.rs:26:55
70 LL | fn elided5(x: &i32) -> (Box<dyn Debug>, impl Debug) { (Box::new(x), x) }
71 | - ^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static`
73 | let's call the lifetime of this reference `'1`
75 help: to declare that the trait object captures data from argument `x`, you can add an explicit `'_` lifetime bound
77 LL | fn elided5(x: &i32) -> (Box<dyn Debug + '_>, impl Debug) { (Box::new(x), x) }
79 help: to declare that `impl Debug` captures data from argument `x`, you can add an explicit `'_` lifetime bound
81 LL | fn elided5(x: &i32) -> (Box<dyn Debug>, impl Debug + '_) { (Box::new(x), x) }
84 error: lifetime may not live long enough
85 --> $DIR/must_outlive_least_region_or_bound.rs:32:69
87 LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
88 | -- lifetime `'a` defined here ^ returning this value requires that `'a` must outlive `'static`
90 help: consider changing `impl LifetimeTrait<'a> + 'static`'s explicit `'static` bound to the lifetime of argument `x`
92 LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'a { x }
94 help: alternatively, add an explicit `'static` bound to this reference
96 LL | fn with_bound<'a>(x: &'static i32) -> impl LifetimeTrait<'a> + 'static { x }
99 error[E0700]: hidden type for `impl Fn(&'a u32)` captures lifetime that does not appear in bounds
100 --> $DIR/must_outlive_least_region_or_bound.rs:38:5
102 LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) {
103 | -- hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:38:5: 38:13]` captures the lifetime `'b` as defined here
104 LL | move |_| println!("{}", y)
105 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
107 help: to declare that `impl Fn(&'a u32)` captures `'b`, you can add an explicit `'b` lifetime bound
109 LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) + 'b {
112 error[E0310]: the parameter type `T` may not live long enough
113 --> $DIR/must_outlive_least_region_or_bound.rs:43:5
116 | ^ ...so that the type `T` will meet its required lifetime bounds
118 help: consider adding an explicit lifetime bound...
120 LL | fn ty_param_wont_outlive_static<T:Debug + 'static>(x: T) -> impl Debug + 'static {
123 error: aborting due to 9 previous errors
125 Some errors have detailed explanations: E0310, E0621, E0700.
126 For more information about an error, try `rustc --explain E0310`.