-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug fix:
#![feature(nll)]
takes precedence over -Z borrowck=migrate
.
(Includes test illustrating desired behavior; compare its diagnostic output to that of the file `borrowck-migreate-to-nll.rs`.)
- Loading branch information
Showing
3 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// 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`. | ||
|
||
// compile-flags: -Z borrowck=migrate | ||
|
||
#![feature(nll)] | ||
|
||
fn main() { | ||
match Some(&4) { | ||
None => {}, | ||
ref mut foo | ||
if { | ||
(|| { let bar = foo; bar.take() })(); | ||
//~^ 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."), | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error[E0507]: cannot move out of borrowed content | ||
--> $DIR/borrowck-feature-nll-overrides-migrate.rs:30:17 | ||
| | ||
LL | (|| { let bar = foo; bar.take() })(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0507`. |