]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.rs
Rollup merge of #53030 - Aaronepower:master, r=Mark-Simulacrum
[rust.git] / src / test / ui / borrowck / borrowck-feature-nll-overrides-migrate.rs
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // This is a test that the `#![feature(nll)]` opt-in overrides the
12 // migration mode. The intention here is to emulate the goal behavior
13 // that `--edition 2018` effects on borrowck (modeled here by `-Z
14 // borrowck=migrate`) are themselves overridden by the
15 // `#![feature(nll)]` opt-in.
16 //
17 // Therefore, for developer convenience, under `#[feature(nll)]` the
18 // NLL checks will be emitted as errors *even* in the presence of `-Z
19 // borrowck=migrate`.
20
21 // revisions: zflag edition
22 // [zflag]compile-flags: -Z borrowck=migrate
23 // [edition]edition:2018
24
25 #![feature(nll)]
26
27 fn main() {
28     match Some(&4) {
29         None => {},
30         ref mut foo
31             if {
32                 (|| { let bar = foo; bar.take() })();
33                 //[zflag]~^ ERROR cannot move out of borrowed content [E0507]
34                 //[edition]~^^ ERROR cannot move out of borrowed content [E0507]
35                 false
36             } => {},
37         Some(ref _s) => println!("Note this arm is bogus; the `Some` became `None` in the guard."),
38         _ => println!("Here is some supposedly unreachable code."),
39     }
40 }