]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/issue-52534.stderr
fc7766885f5efa1f9099ef1c93ed9515ddf57dce
[rust.git] / src / test / ui / nll / issue-52534.stderr
1 error[E0597]: `x` does not live long enough
2   --> $DIR/issue-52534.rs:22:14
3    |
4 LL |     foo(|a| &x)
5    |          -   ^ `x` would have to be valid for `'0`
6    |          |
7    |          has type `&'0 u32`
8 LL | }
9    | - ...but `x` is only valid for the duration of the `bar` function, so it is dropped here while still borrowed
10    |
11    = note: functions cannot return a borrow to data owned within the function's scope, functions can only return borrows to data passed as arguments
12    = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch04-02-references-and-borrowing.html#dangling-references>
13
14 error[E0597]: `y` does not live long enough
15   --> $DIR/issue-52534.rs:27:26
16    |
17 LL |     baz(|first, second| &y)
18    |          -----           ^ `y` would have to be valid for `'0`
19    |          |
20    |          has type `&'0 u32`
21 LL | }
22    | - ...but `y` is only valid for the duration of the `foobar` function, so it is dropped here while still borrowed
23    |
24    = note: functions cannot return a borrow to data owned within the function's scope, functions can only return borrows to data passed as arguments
25    = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch04-02-references-and-borrowing.html#dangling-references>
26
27 error: aborting due to 2 previous errors
28
29 For more information about this error, try `rustc --explain E0597`.