2a3969a3f7
This gives at least some explanation for why a borrow is expected to last for a certain free region. Also: * Reports E0373: "closure may outlive the current function" with NLL. * Special cases the case of returning a reference to (or value referencing) a local variable or temporary (E0515). * Special case assigning a reference to a local variable in a closure to a captured variable.
22 lines
887 B
Plaintext
22 lines
887 B
Plaintext
error[E0515]: cannot return reference to temporary value
|
|
--> $DIR/regions-creating-enums.rs:33:16
|
|
|
|
|
LL | return &ast::num((*f)(x)); //~ ERROR borrowed value does not live long enough
|
|
| ^-----------------
|
|
| ||
|
|
| |temporary value created here
|
|
| returns a reference to data owned by the current function
|
|
|
|
error[E0515]: cannot return reference to temporary value
|
|
--> $DIR/regions-creating-enums.rs:38:16
|
|
|
|
|
LL | return &ast::add(m_x, m_y); //~ ERROR borrowed value does not live long enough
|
|
| ^------------------
|
|
| ||
|
|
| |temporary value created here
|
|
| returns a reference to data owned by the current function
|
|
|
|
error: aborting due to 2 previous errors
|
|
|
|
For more information about this error, try `rustc --explain E0515`.
|