rust/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.rs
2018-12-25 21:08:33 -07:00

31 lines
1.1 KiB
Rust

// This is a test that the `#![feature(nll)]` opt-in overrides the
// migration mode. The intention here is to emulate the goal behavior
// that `--edition 2018` effects on borrowck (modeled here by `-Z
// borrowck=migrate`) are themselves overridden by the
// `#![feature(nll)]` opt-in.
//
// Therefore, for developer convenience, under `#[feature(nll)]` the
// NLL checks will be emitted as errors *even* in the presence of `-Z
// borrowck=migrate`.
// revisions: zflag edition
// [zflag]compile-flags: -Z borrowck=migrate
// [edition]edition:2018
#![feature(nll)]
fn main() {
match Some(&4) {
None => {},
ref mut foo
if {
(|| { let bar = foo; bar.take() })();
//[zflag]~^ ERROR cannot move out of borrowed content [E0507]
//[edition]~^^ ERROR cannot move out of borrowed content [E0507]
false
} => {},
Some(ref _s) => println!("Note this arm is bogus; the `Some` became `None` in the guard."),
_ => println!("Here is some supposedly unreachable code."),
}
}