]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.rs
Update tests for changes to cannot move errors
[rust.git] / src / test / ui / borrowck / borrowck-feature-nll-overrides-migrate.rs
1 // This is a test that the `#![feature(nll)]` opt-in overrides the
2 // migration mode. The intention here is to emulate the goal behavior
3 // that `--edition 2018` effects on borrowck (modeled here by `-Z
4 // borrowck=migrate`) are themselves overridden by the
5 // `#![feature(nll)]` opt-in.
6 //
7 // Therefore, for developer convenience, under `#[feature(nll)]` the
8 // NLL checks will be emitted as errors *even* in the presence of `-Z
9 // borrowck=migrate`.
10
11 // revisions: zflag edition
12 // [zflag]compile-flags: -Z borrowck=migrate
13 // [edition]edition:2018
14
15 #![feature(nll)]
16
17 fn main() {
18     match Some(&4) {
19         None => {},
20         ref mut foo
21             if {
22                 (|| { let bar = foo; bar.take() })();
23                 //[zflag]~^ ERROR cannot move out of `foo` in pattern guard [E0507]
24                 //[edition]~^^ ERROR cannot move out of `foo` in pattern guard [E0507]
25                 false
26             } => {},
27         Some(ref _s) => println!("Note this arm is bogus; the `Some` became `None` in the guard."),
28         _ => println!("Here is some supposedly unreachable code."),
29     }
30 }