rust/src/test/ui/regions/regions-creating-enums.nll.stderr
Matthew Jasper 2a3969a3f7 Use new region infer errors for explaining borrows
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.
2018-10-21 12:35:00 +01:00

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`.