]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/outlives-suggestion-simple.stderr
6300ea66511fb9f7a0a1709c7a9f775a80772623
[rust.git] / src / test / ui / nll / outlives-suggestion-simple.stderr
1 error: lifetime may not live long enough
2   --> $DIR/outlives-suggestion-simple.rs:6:5
3    |
4 LL | fn foo1<'a, 'b>(x: &'a usize) -> &'b usize {
5    |         --  -- lifetime `'b` defined here
6    |         |
7    |         lifetime `'a` defined here
8 LL |     x
9    |     ^ returning this value requires that `'a` must outlive `'b`
10    |
11    = help: consider adding the following bound: `'a: 'b`
12
13 error: lifetime may not live long enough
14   --> $DIR/outlives-suggestion-simple.rs:10:5
15    |
16 LL | fn foo2<'a>(x: &'a usize) -> &'static usize {
17    |         -- lifetime `'a` defined here
18 LL |     x
19    |     ^ returning this value requires that `'a` must outlive `'static`
20    |
21    = help: consider replacing `'a` with `'static`
22
23 error: lifetime may not live long enough
24   --> $DIR/outlives-suggestion-simple.rs:14:5
25    |
26 LL | 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
30 LL |     (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
35 error: lifetime may not live long enough
36   --> $DIR/outlives-suggestion-simple.rs:14:5
37    |
38 LL | 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
42 LL |     (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
47 help: `'a` and `'b` must be the same: replace one with the other
48
49 error: lifetime may not live long enough
50   --> $DIR/outlives-suggestion-simple.rs:22:5
51    |
52 LL | fn foo4<'a, 'b, 'c>(x: &'a usize) -> (&'b usize, &'c usize) {
53    |         --  -- lifetime `'b` defined here
54    |         |
55    |         lifetime `'a` defined here
56 ...
57 LL |     (x, x)
58    |     ^^^^^^ returning this value requires that `'a` must outlive `'b`
59    |
60    = help: consider adding the following bound: `'a: 'b`
61
62 error: lifetime may not live long enough
63   --> $DIR/outlives-suggestion-simple.rs:31:9
64    |
65 LL |     pub fn foo<'a>(x: &'a usize) -> Self {
66    |                -- lifetime `'a` defined here
67 LL |         Foo { x }
68    |         ^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
69    |
70    = help: consider replacing `'a` with `'static`
71
72 error: lifetime may not live long enough
73   --> $DIR/outlives-suggestion-simple.rs:41:9
74    |
75 LL | impl<'a> Bar<'a> {
76    |      -- lifetime `'a` defined here
77 LL |     pub fn get<'b>(&self) -> &'b usize {
78    |                -- lifetime `'b` defined here
79 LL |         self.x
80    |         ^^^^^^ returning this value requires that `'a` must outlive `'b`
81    |
82    = help: consider adding the following bound: `'a: 'b`
83
84 error: lifetime may not live long enough
85   --> $DIR/outlives-suggestion-simple.rs:52:9
86    |
87 LL | impl<'a> Baz<'a> {
88    |      -- lifetime `'a` defined here
89 LL |     fn get<'b>(&'b self) -> &'a i32 {
90    |            -- lifetime `'b` defined here
91 LL |         self.x
92    |         ^^^^^^ returning this value requires that `'b` must outlive `'a`
93    |
94    = help: consider adding the following bound: `'b: 'a`
95
96 error[E0521]: borrowed data escapes outside of associated function
97   --> $DIR/outlives-suggestion-simple.rs:73:9
98    |
99 LL |     fn get_bar(&self) -> Bar2 {
100    |                -----
101    |                |
102    |                `self` declared here, outside of the associated function body
103    |                `self` is a reference that is only valid in the associated function body
104 LL |         Bar2::new(&self)
105    |         ^^^^^^^^^^^^^^^^ `self` escapes the associated function body here
106
107 error: aborting due to 9 previous errors
108