Description
D'oh: while investigating #52979, I found a case where we are downgrading the NLL errors to warnings (due to the migration mode added in #52681), but AST-borrowck issues an error for the test! (This may explain #53004, at least in part...)
Namely, ui/borrowck/issue-45983.rs. Here is the test:
rust/src/test/ui/borrowck/issue-45983.rs
Lines 11 to 19 in e415b5e
Here is the AST-borrowck output (a hard error):
rust/src/test/ui/borrowck/issue-45983.stderr
Lines 1 to 11 in e415b5e
And here is the NLL output (another hard error):
rust/src/test/ui/borrowck/issue-45983.nll.stderr
Lines 1 to 25 in e415b5e
But here is the output from -Z borrowck=migrate -Z two-phase-borrows
:
warning: not reporting region error due to nll
--> ../src/test/ui/borrowck/issue-45983.rs:17:27
|
17 | give_any(|y| x = Some(y));
| ^
warning: borrowed data escapes outside of closure
--> ../src/test/ui/borrowck/issue-45983.rs:17:18
|
16 | let x = None;
| - `x` is declared here, outside of the closure body
17 | give_any(|y| x = Some(y));
| - ^^^^^^^^^^^ `y` escapes the closure body here
| |
| `y` is a reference that is only valid in the closure body
|
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
It represents potential unsoundness in your code.
This warning will become a hard error in the future.
warning[E0594]: cannot assign to `x`, as it is not declared as mutable
--> ../src/test/ui/borrowck/issue-45983.rs:17:18
|
16 | let x = None;
| - help: consider changing this to be mutable: `mut x`
17 | give_any(|y| x = Some(y));
| ^^^^^^^^^^^ cannot assign
|
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
It represents potential unsoundness in your code.
This warning will become a hard error in the future.
ui/borrowck/issue-45983.rs is one particular instance of this, but now that I've found one, I'm certain there are more.
This is pretty bad. Very high priority to fix.