rust/src/test/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.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

44 lines
1.8 KiB
Plaintext

error[E0713]: borrow may still be in use when destructor runs
--> $DIR/issue-52059-report-when-borrow-and-drop-conflict.rs:14:5
|
LL | fn finish_1(s: S) -> &mut String {
| - has type `S<'1>`
LL | s.url
| ^^^^^ returning this value requires that `*s.url` is borrowed for `'1`
LL | }
| - here, drop of `s` needs exclusive access to `*s.url`, because the type `S<'_>` implements the `Drop` trait
error[E0713]: borrow may still be in use when destructor runs
--> $DIR/issue-52059-report-when-borrow-and-drop-conflict.rs:19:13
|
LL | fn finish_2(s: S) -> &mut String {
| - has type `S<'1>`
LL | let p = &mut *s.url; p
| ^^^^^^^^^^^ - returning this value requires that `*s.url` is borrowed for `'1`
LL | }
| - here, drop of `s` needs exclusive access to `*s.url`, because the type `S<'_>` implements the `Drop` trait
error[E0713]: borrow may still be in use when destructor runs
--> $DIR/issue-52059-report-when-borrow-and-drop-conflict.rs:24:21
|
LL | fn finish_3(s: S) -> &mut String {
| - has type `S<'1>`
LL | let p: &mut _ = s.url; p
| ^^^^^ - returning this value requires that `*s.url` is borrowed for `'1`
LL | }
| - here, drop of `s` needs exclusive access to `*s.url`, because the type `S<'_>` implements the `Drop` trait
error[E0509]: cannot move out of type `S<'_>`, which implements the `Drop` trait
--> $DIR/issue-52059-report-when-borrow-and-drop-conflict.rs:29:13
|
LL | let p = s.url; p
| ^^^^^
| |
| cannot move out of here
| help: consider borrowing here: `&s.url`
error: aborting due to 4 previous errors
Some errors occurred: E0509, E0713.
For more information about an error, try `rustc --explain E0509`.