2018-03-01 08:56:43 -06:00
|
|
|
error[E0597]: `v` does not live long enough
|
2018-03-05 16:29:05 -06:00
|
|
|
--> $DIR/borrowed-universal-error-2.rs:16:5
|
2018-03-01 08:56:43 -06:00
|
|
|
|
|
2018-09-14 08:44:45 -05:00
|
|
|
LL | fn foo<'a>(x: &'a (u32,)) -> &'a u32 {
|
2018-09-18 14:28:06 -05:00
|
|
|
| -- -- also has lifetime `'a`
|
|
|
|
| |
|
|
|
|
| has lifetime `'a`
|
2018-09-14 08:44:45 -05:00
|
|
|
LL | let v = 22;
|
2018-03-01 08:56:43 -06:00
|
|
|
LL | &v
|
2018-09-18 19:48:47 -05:00
|
|
|
| ^^ `v` would have to be valid for `'a`...
|
2018-03-01 08:56:43 -06:00
|
|
|
LL | //~^ ERROR `v` does not live long enough [E0597]
|
|
|
|
LL | }
|
2018-09-18 19:48:47 -05:00
|
|
|
| - ...but `v` will be dropped here, when the function `foo` returns
|
2018-09-17 13:49:21 -05:00
|
|
|
|
|
2018-09-18 14:28:06 -05:00
|
|
|
= help: use data from the highlighted arguments which match the `'a` lifetime of the return type
|
2018-09-17 13:49:21 -05:00
|
|
|
= note: functions cannot return a borrow to data owned within the function's scope, functions can only return borrows to data passed as arguments
|
|
|
|
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch04-02-references-and-borrowing.html#dangling-references>
|
2018-03-01 08:56:43 -06:00
|
|
|
|
|
|
|
error: aborting due to previous error
|
|
|
|
|
2018-03-03 08:59:40 -06:00
|
|
|
For more information about this error, try `rustc --explain E0597`.
|