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
{{ message }}
Repository navigation
Erroneous borrow error from 2018 edition's NLL migration mode. #52967
warning[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
--> src/config.rs:259:40
|
257 | match &mut self.target_dir {
| -------------------- immutable borrow occurs here
258 | // We require an absolute path, so adjust a relative one if it's passed.
259 | Inferrable::Specified(Some(ref mut path)) if path.is_relative() => {
| ^^^^^^^^^^^^ mutable borrow occurs here
...
262 | _ => {},
| - borrow later used here
|
= 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.
The warning is the same without the &mut.
It seems to me this code is fine and there should not be a warning.
warning[E0502]: cannot borrow `stuff.0` as mutable because it is also borrowed as immutable
--> src/main.rs:4:10
|
3 | match stuff {
| ----- immutable borrow occurs here
4 | (ref mut left, _) if *left == "left" => { }
| ^^^^^^^^^^^^ mutable borrow occurs here
5 | _ => {}
| - borrow later used here
|
= 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.
There is a bug in how I linked the migration mode into the 2018 edition (PR #52681). Basically, its not toggling on enough switches, and one of the ones I missed is causing something to break with the new way we handle match.
This issue strikes me as an argument that we should turn on something analogous to compare-mode=nll in compiletest, except specialized to just the 2018 edition opt-in, rather than turning on NLL via debug switches.
In particular, you see the error with -Z borrowck=mir, but not with -Z borrowck=mir -Z two-phase-borrows. That's a pretty strong hint that I forgot to have edition=2008 imply two-phase-borrows.
Activity
pnkfelix commentedon Aug 2, 2018
Smaller example (playground):
which emits the diagnostic:
pnkfelix commentedon Aug 2, 2018
Here's the (very?) good news: this is not an NLL bug, per se.
In particular, when we opt into NLL explicitly, the example works (playground):
There is a bug in how I linked the migration mode into the 2018 edition (PR #52681). Basically, its not toggling on enough switches, and one of the ones I missed is causing something to break with the new way we handle
match.[-]Erroneous borrow error from NLL[/-][+]Erroneous borrow error from 2018 edition's NLL migration mode.[/+]pnkfelix commentedon Aug 2, 2018
This issue strikes me as an argument that we should turn on something analogous to
compare-mode=nllincompiletest, except specialized to just the 2018 edition opt-in, rather than turning on NLL via debug switches.pnkfelix commentedon Aug 2, 2018
In particular, you see the error with
-Z borrowck=mir, but not with-Z borrowck=mir -Z two-phase-borrows. That's a pretty strong hint that I forgot to have edition=2008 imply two-phase-borrows.When we turn on NLL migration in the 2018 edition, we need two-phase …
Auto merge of #52975 - pnkfelix:issue-52967-edition-2018-implies-2-ph…