]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/regions-nested-fns-2.nll.stderr
Correctly handle named lifetimes.
[rust.git] / src / test / ui / regions / regions-nested-fns-2.nll.stderr
1 error[E0597]: `y` does not live long enough
2   --> $DIR/regions-nested-fns-2.rs:18:25
3    |
4 LL |         |z| {
5    |          - has type `&'0 isize`
6 LL |             //~^ ERROR E0373
7 LL |             if false { &y } else { z }
8    |                         ^ `y` would have to be valid for `'0`
9 LL |         });
10 LL | }
11    | - but `y` will be dropped here, when the function `nested` returns
12    |
13    = note: functions cannot return a borrow to data owned within the function's scope, functions can only return borrows to data passed as arguments
14    = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch04-02-references-and-borrowing.html#dangling-references>
15
16 error: aborting due to previous error
17
18 For more information about this error, try `rustc --explain E0597`.