]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-30438-c.nll.stderr
Correctly handle named lifetimes.
[rust.git] / src / test / ui / issues / issue-30438-c.nll.stderr
1 error[E0597]: `x` does not live long enough
2   --> $DIR/issue-30438-c.rs:19:5
3    |
4 LL | fn silly<'y, 'z>(_s: &'y Test<'z>) -> &'y <Test<'z> as Trait>::Out where 'z: 'static {
5    |                       --               -- also has lifetime `'y`
6    |                       |
7    |                       has lifetime `'y`
8 LL |     let x = Test { s: "this cannot last" };
9 LL |     &x
10    |     ^^ `x` would have to be valid for `'y`
11 LL |     //~^ ERROR: `x` does not live long enough
12 LL | }
13    | - but `x` will be dropped here, when the function `silly` returns
14    |
15    = help: use data from the highlighted arguments which match the `'y` lifetime of the return type
16    = note: functions cannot return a borrow to data owned within the function's scope, functions can only return borrows to data passed as arguments
17    = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch04-02-references-and-borrowing.html#dangling-references>
18
19 error: aborting due to previous error
20
21 For more information about this error, try `rustc --explain E0597`.