fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #72883 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum49cae55760d

1.44.0
4.2 KiB123 linesraw
1error: lifetime may not live long enough
2  --> $DIR/outlives-suggestion-simple.rs:6:5
3   |
4LL | fn foo1<'a, 'b>(x: &'a usize) -> &'b usize {
5   |         --  -- lifetime `'b` defined here
6   |         |
7   |         lifetime `'a` defined here
8LL |     x
9   |     ^ returning this value requires that `'a` must outlive `'b`
10   |
11   = help: consider adding the following bound: `'a: 'b`
12
13error: lifetime may not live long enough
14  --> $DIR/outlives-suggestion-simple.rs:10:5
15   |
16LL | fn foo2<'a>(x: &'a usize) -> &'static usize {
17   |         -- lifetime `'a` defined here
18LL |     x
19   |     ^ returning this value requires that `'a` must outlive `'static`
20   |
21   = help: consider replacing `'a` with `'static`
22
23error: lifetime may not live long enough
24  --> $DIR/outlives-suggestion-simple.rs:14:5
25   |
26LL | fn foo3<'a, 'b>(x: &'a usize, y: &'b usize) -> (&'b usize, &'a usize) {
27   |         --  -- lifetime `'b` defined here
28   |         |
29   |         lifetime `'a` defined here
30LL |     (x, y)
31   |     ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
32   |
33   = help: consider adding the following bound: `'a: 'b`
34
35error: lifetime may not live long enough
36  --> $DIR/outlives-suggestion-simple.rs:14:5
37   |
38LL | fn foo3<'a, 'b>(x: &'a usize, y: &'b usize) -> (&'b usize, &'a usize) {
39   |         --  -- lifetime `'b` defined here
40   |         |
41   |         lifetime `'a` defined here
42LL |     (x, y)
43   |     ^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`
44   |
45   = help: consider adding the following bound: `'b: 'a`
46
47help: `'a` and `'b` must be the same: replace one with the other
48
49error: lifetime may not live long enough
50  --> $DIR/outlives-suggestion-simple.rs:22:5
51   |
52LL | fn foo4<'a, 'b, 'c>(x: &'a usize) -> (&'b usize, &'c usize) {
53   |         --  -- lifetime `'b` defined here
54   |         |
55   |         lifetime `'a` defined here
56...
57LL |     (x, x)
58   |     ^^^^^^ returning this value requires that `'a` must outlive `'b`
59   |
60   = help: consider adding the following bound: `'a: 'b`
61
62error: lifetime may not live long enough
63  --> $DIR/outlives-suggestion-simple.rs:22:5
64   |
65LL | fn foo4<'a, 'b, 'c>(x: &'a usize) -> (&'b usize, &'c usize) {
66   |         --      -- lifetime `'c` defined here
67   |         |
68   |         lifetime `'a` defined here
69...
70LL |     (x, x)
71   |     ^^^^^^ returning this value requires that `'a` must outlive `'c`
72   |
73   = help: consider adding the following bound: `'a: 'c`
74
75help: add bound `'a: 'b + 'c`
76
77error: lifetime may not live long enough
78  --> $DIR/outlives-suggestion-simple.rs:31:9
79   |
80LL |     pub fn foo<'a>(x: &'a usize) -> Self {
81   |                -- lifetime `'a` defined here
82LL |         Foo { x }
83   |         ^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
84   |
85   = help: consider replacing `'a` with `'static`
86
87error: lifetime may not live long enough
88  --> $DIR/outlives-suggestion-simple.rs:41:9
89   |
90LL | impl<'a> Bar<'a> {
91   |      -- lifetime `'a` defined here
92LL |     pub fn get<'b>(&self) -> &'b usize {
93   |                -- lifetime `'b` defined here
94LL |         self.x
95   |         ^^^^^^ returning this value requires that `'a` must outlive `'b`
96   |
97   = help: consider adding the following bound: `'a: 'b`
98
99error: lifetime may not live long enough
100  --> $DIR/outlives-suggestion-simple.rs:52:9
101   |
102LL | impl<'a> Baz<'a> {
103   |      -- lifetime `'a` defined here
104LL |     fn get<'b>(&'b self) -> &'a i32 {
105   |            -- lifetime `'b` defined here
106LL |         self.x
107   |         ^^^^^^ returning this value requires that `'b` must outlive `'a`
108   |
109   = help: consider adding the following bound: `'b: 'a`
110
111error[E0521]: borrowed data escapes outside of associated function
112  --> $DIR/outlives-suggestion-simple.rs:73:9
113   |
114LL |     fn get_bar(&self) -> Bar2 {
115   |                -----
116   |                |
117   |                `self` declared here, outside of the associated function body
118   |                `self` is a reference that is only valid in the associated function body
119LL |         Bar2::new(&self)
120   |         ^^^^^^^^^^^^^^^^ `self` escapes the associated function body here
121
122error: aborting due to 10 previous errors
123