Change:
D'oh: while investigating , I found a case where we are downgrading the NLL errors to warnings (due to the migration mode in ), but AST-borrowck issues an error for the test! (This may explain , at least in part...) Namely, . Here is the test: Here is the AST-borrowck output (a hard error): And here is the NLL output (another hard error): But here is the output from : ui/borrowck/issue- 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.
This code looks suspicious:
Ha I should have just left this to to fix, since we seem to have independently identified the culprit.
I think I've already assigned myself to enough issues.

Discussion:
) { debug!("report_region_errors(): {} errors to start", errors.len()); <del> if will_later_be_reported_by_nll && self.tcx.use_mir_borrowck() { </del> <ins> if will_later_be_reported_by_nll && // FIXME: `use_mir_borrowck` seems wrong here... self.tcx.use_mir_borrowck() && // ... this is a band-aid; may be better to explicitly // match on every borrowck_mode variant to guide decision // here. !self.tcx.migrate_borrowck() { </ins> // With `#![feature(nll)]`, we want to present a nice user // experience, so don't even mention the errors from the // AST checker.

<ins> error: borrowed data cannot be stored outside of its closure --> $DIR/issue-45983.rs:36:27 | LL |     let x = None; |         - borrowed data cannot be stored into here... LL |     give_any(|y| x = Some(y)); |              ---          ^ cannot be stored outside of its closure |              | |              ...because it cannot outlive this closure error: aborting due to previous error </ins>

warning: not reporting region error due to nll <del> --> $DIR/issue-45983.rs:17:27 </del> <ins> --> $DIR/issue-45983.rs:36:27 </ins> | LL |     give_any(|y| x = Some(y)); |                           ^ error: borrowed data escapes outside of closure <del> --> $DIR/issue-45983.rs:17:18 </del> <ins> --> $DIR/issue-45983.rs:36:18 </ins> | LL |     let x = None; |         - `x` is declared here, outside of the closure body

|               `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 <del> --> $DIR/issue-45983.rs:17:18 </del> <ins> --> $DIR/issue-45983.rs:36:18 </ins> | LL |     let x = None; |         - help: consider changing this to be mutable: `mut x`

// option. This file may not be copied, modified, or distributed // except according to those terms. <ins> // As documented in Issue #45983, this test is evaluating the quality // of our diagnostics on erroneous code using higher-ranked closures. // // However, as documented on Issue #53026, this test also became a // prime example of our need to test the NLL migration mode // *separately* from the existing test suites that focus solely on // AST-borrwock and NLL. // revisions: ast migrate nll // Since we are testing nll (and migration) explicitly as a separate // revisions, dont worry about the --compare-mode=nll on this test. // ignore-compare-mode-nll //[ast]compile-flags: -Z borrowck=ast //[migrate]compile-flags: -Z borrowck=migrate -Z two-phase-borrows //[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows </ins> fn give_any<F: for<'r> FnOnce(&'r ())>(f: F) { f(&()); }

fn main() { let x = None; give_any(|y| x = Some(y)); <del> //~^ ERROR borrowed data cannot be stored outside of its closure </del> <ins> //[ast]~^ ERROR borrowed data cannot be stored outside of its closure //[migrate]~^^ ERROR borrowed data cannot be stored outside of its closure //[nll]~^^^ WARN not reporting region error due to nll //[nll]~| ERROR borrowed data escapes outside of closure //[nll]~| ERROR cannot assign to `x`, as it is not declared as mutable </ins> }

<del> error: borrowed data cannot be stored outside of its closure --> $DIR/issue-45983.rs:17:27 | LL |     let x = None; |         - borrowed data cannot be stored into here... LL |     give_any(|y| x = Some(y)); |              ---          ^ cannot be stored outside of its closure |              | |              ...because it cannot outlive this closure error: aborting due to previous error </del>