1 // As documented in Issue #45983, this test is evaluating the quality
2 // of our diagnostics on erroneous code using higher-ranked closures.
4 // revisions: migrate nll
6 // Since we are testing nll (and migration) explicitly as a separate
7 // revisions, don't worry about the --compare-mode=nll on this test.
9 // ignore-compare-mode-nll
10 // ignore-compare-mode-polonius
12 //[nll]compile-flags: -Z borrowck=mir
14 fn give_any<F: for<'r> FnOnce(&'r ())>(f: F) {
20 give_any(|y| x = Some(y));
21 //[migrate]~^ ERROR borrowed data cannot be stored outside of its closure
22 //[nll]~^^ ERROR borrowed data escapes outside of closure
23 //[nll]~| ERROR cannot assign to `x`, as it is not declared as mutable