]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/issue-52534-1.stderr
2400cb72a385d94bc0446ceb442098f124649272
[rust.git] / src / test / ui / nll / issue-52534-1.stderr
1 error[E0597]: `x` does not live long enough
2   --> $DIR/issue-52534-1.rs:19:9
3    |
4 LL |     fn bar(&self, x: &u32) -> &u32 {
5    |            -----              ---- has type `&'0 u32`
6    |            |
7    |            has type `&'0 Test`
8 LL |         let x = 22;
9 LL |         &x
10    |         ^^ `x` would have to be valid for `'0`
11 LL |     }
12    |     - ...but `x` is only valid for the duration of the `bar` function, so it is dropped here while still borrowed
13    |
14    = note: functions cannot return a borrow to data owned within the function's scope, functions can only return borrows to data passed as arguments
15    = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch04-02-references-and-borrowing.html#dangling-references>
16
17 error[E0597]: `x` does not live long enough
18   --> $DIR/issue-52534-1.rs:25:5
19    |
20 LL | fn foo(x: &u32) -> &u32 {
21    |           ----     ---- also has type `&'0 u32`
22    |           |
23    |           has type `&'0 u32`
24 LL |     let x = 22;
25 LL |     &x
26    |     ^^ `x` would have to be valid for `'0`
27 LL | }
28    | - ...but `x` is only valid for the duration of the `foo` function, so it is dropped here while still borrowed
29    |
30    = note: functions cannot return a borrow to data owned within the function's scope, functions can only return borrows to data passed as arguments
31    = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch04-02-references-and-borrowing.html#dangling-references>
32
33 error[E0597]: `x` does not live long enough
34   --> $DIR/issue-52534-1.rs:30:6
35    |
36 LL | fn baz(x: &u32) -> &&u32 {
37    |           ----     ----- has type `&'0 &'0 u32`
38    |           |
39    |           has type `&'0 u32`
40 LL |     let x = 22;
41 LL |     &&x
42    |      ^^ `x` would have to be valid for `'0`
43 LL | }
44    | - ...but `x` is only valid for the duration of the `baz` function, so it is dropped here while still borrowed
45    |
46    = note: functions cannot return a borrow to data owned within the function's scope, functions can only return borrows to data passed as arguments
47    = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch04-02-references-and-borrowing.html#dangling-references>
48
49 error[E0597]: borrowed value does not live long enough
50   --> $DIR/issue-52534-1.rs:30:6
51    |
52 LL |     &&x
53    |      ^^ temporary value does not live long enough
54 LL | }
55    | - temporary value only lives until here
56    |
57 note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 28:1...
58   --> $DIR/issue-52534-1.rs:28:1
59    |
60 LL | / fn baz(x: &u32) -> &&u32 {
61 LL | |     let x = 22;
62 LL | |     &&x
63 LL | | }
64    | |_^
65
66 error: aborting due to 4 previous errors
67
68 For more information about this error, try `rustc --explain E0597`.