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