summaryrefslogtreecommitdiffstats
path: root/tests/ui/nll/outlives-suggestion-simple.polonius.stderr
blob: c00288f2e3c73b6d9b3623001bfdd5253c523dbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
error: lifetime may not live long enough
  --> $DIR/outlives-suggestion-simple.rs:6:5
   |
LL | fn foo1<'a, 'b>(x: &'a usize) -> &'b usize {
   |         --  -- lifetime `'b` defined here
   |         |
   |         lifetime `'a` defined here
LL |     x
   |     ^ returning this value requires that `'a` must outlive `'b`
   |
   = help: consider adding the following bound: `'a: 'b`

error: lifetime may not live long enough
  --> $DIR/outlives-suggestion-simple.rs:10:5
   |
LL | fn foo2<'a>(x: &'a usize) -> &'static usize {
   |         -- lifetime `'a` defined here
LL |     x
   |     ^ returning this value requires that `'a` must outlive `'static`
   |
   = help: consider replacing `'a` with `'static`

error: lifetime may not live long enough
  --> $DIR/outlives-suggestion-simple.rs:14:5
   |
LL | fn foo3<'a, 'b>(x: &'a usize, y: &'b usize) -> (&'b usize, &'a usize) {
   |         --  -- lifetime `'b` defined here
   |         |
   |         lifetime `'a` defined here
LL |     (x, y)
   |     ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
   |
   = help: consider adding the following bound: `'a: 'b`

error: lifetime may not live long enough
  --> $DIR/outlives-suggestion-simple.rs:14:5
   |
LL | fn foo3<'a, 'b>(x: &'a usize, y: &'b usize) -> (&'b usize, &'a usize) {
   |         --  -- lifetime `'b` defined here
   |         |
   |         lifetime `'a` defined here
LL |     (x, y)
   |     ^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`
   |
   = help: consider adding the following bound: `'b: 'a`

help: `'a` and `'b` must be the same: replace one with the other

error: lifetime may not live long enough
  --> $DIR/outlives-suggestion-simple.rs:22:5
   |
LL | fn foo4<'a, 'b, 'c>(x: &'a usize) -> (&'b usize, &'c usize) {
   |         --  -- lifetime `'b` defined here
   |         |
   |         lifetime `'a` defined here
...
LL |     (x, x)
   |     ^^^^^^ returning this value requires that `'a` must outlive `'b`
   |
   = help: consider adding the following bound: `'a: 'b`

error: lifetime may not live long enough
  --> $DIR/outlives-suggestion-simple.rs:22:5
   |
LL | fn foo4<'a, 'b, 'c>(x: &'a usize) -> (&'b usize, &'c usize) {
   |         --      -- lifetime `'c` defined here
   |         |
   |         lifetime `'a` defined here
...
LL |     (x, x)
   |     ^^^^^^ returning this value requires that `'a` must outlive `'c`
   |
   = help: consider adding the following bound: `'a: 'c`

help: add bound `'a: 'b + 'c`

error: lifetime may not live long enough
  --> $DIR/outlives-suggestion-simple.rs:31:9
   |
LL |     pub fn foo<'a>(x: &'a usize) -> Self {
   |                -- lifetime `'a` defined here
LL |         Foo { x }
   |         ^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
   |
   = help: consider replacing `'a` with `'static`

error: lifetime may not live long enough
  --> $DIR/outlives-suggestion-simple.rs:41:9
   |
LL | impl<'a> Bar<'a> {
   |      -- lifetime `'a` defined here
LL |     pub fn get<'b>(&self) -> &'b usize {
   |                -- lifetime `'b` defined here
LL |         self.x
   |         ^^^^^^ returning this value requires that `'a` must outlive `'b`
   |
   = help: consider adding the following bound: `'a: 'b`

error: lifetime may not live long enough
  --> $DIR/outlives-suggestion-simple.rs:52:9
   |
LL | impl<'a> Baz<'a> {
   |      -- lifetime `'a` defined here
LL |     fn get<'b>(&'b self) -> &'a i32 {
   |            -- lifetime `'b` defined here
LL |         self.x
   |         ^^^^^^ returning this value requires that `'b` must outlive `'a`
   |
   = help: consider adding the following bound: `'b: 'a`

error[E0521]: borrowed data escapes outside of associated function
  --> $DIR/outlives-suggestion-simple.rs:73:9
   |
LL |     fn get_bar(&self) -> Bar2 {
   |                -----
   |                |
   |                `self` declared here, outside of the associated function body
   |                `self` is a reference that is only valid in the associated function body
LL |         Bar2::new(&self)
   |         ^^^^^^^^^^^^^^^^ `self` escapes the associated function body here

error: aborting due to 10 previous errors

For more information about this error, try `rustc --explain E0521`.