You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pnkfelix opened this issue
Aug 3, 2018
· 3 comments
· Fixed by #53045
Assignees
Labels
A-NLLArea: Non-lexical lifetimes (NLL)I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessNLL-soundWorking towards the "invalid code does not compile" goalP-highHigh priority
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...)
| - `x` is declared here, outside of the closure body
LL | give_any(|y| x = Some(y));
| - ^^^^^^^^^^^ `y` escapes the closure body here
| |
| `y` is a reference that is only valid in the closure body
error[E0594]: cannot assign to `x`, as it is not declared as mutable
--> $DIR/issue-45983.rs:17:18
|
LL | let x = None;
| - help: consider changing this to be mutable: `mut x`
LL | give_any(|y| x = Some(y));
| ^^^^^^^^^^^ cannot assign
error: aborting due to 2 previous errors
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.
The text was updated successfully, but these errors were encountered:
…-ast-borrowck, r=estebank
Fix NLL migration mode so that reports region errors when necessary.
The code here was trying to be clever, and say "lets not report diagnostics when we 'know' NLL will report an error about them in the future."
The problem is that in migration mode, when no error was reported here, the NLL error that we "knew" was coming was downgraded to a warning (!).
Thus causing #53026
(I hope it is the only instance of such a scenario, but we will see.)
Anyway, this PR fixes that by only doing the "clever" skipping of region error reporting when we are not in migration mode. As noted in the FIXME, I'm not really thrilled with this band-aid, but it is small enough to be back-ported easily if that is necessary.
Rather than make a separate test for issue 53026, I just took the test that uncovered this in a first place, and extended it (via our revisions system) to explicitly show all three modes in action: AST-borrowck, NLL, and NLL migration mode.
(To be honest I hope not to have to add such revisions to many tests. Instead I hope to adopt some sort of new `compare-mode` for either borrowck=migrate or for the 2018 edition as a whole.)
Fix#53026
A-NLLArea: Non-lexical lifetimes (NLL)I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessNLL-soundWorking towards the "invalid code does not compile" goalP-highHigh priority
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
: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.
The text was updated successfully, but these errors were encountered: