Skip to content

Commit

Permalink
Incorporate edition flag testing into tests of -Z borrowck=migrate.
Browse files Browse the repository at this point in the history
  • Loading branch information
pnkfelix committed Jul 26, 2018
1 parent 94a2972 commit 9f05f29
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 7 deletions.
@@ -1,5 +1,5 @@
error[E0507]: cannot move out of borrowed content
--> $DIR/borrowck-feature-nll-overrides-migrate.rs:30:17
--> $DIR/borrowck-feature-nll-overrides-migrate.rs:32:17
|
LL | (|| { let bar = foo; bar.take() })();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
Expand Down
Expand Up @@ -18,7 +18,9 @@
// NLL checks will be emitted as errors *even* in the presence of `-Z
// borrowck=migrate`.

// compile-flags: -Z borrowck=migrate
// revisions: zflag edition
// [zflag]compile-flags: -Z borrowck=migrate
// [edition]compile-flags: --edition 2018

#![feature(nll)]

Expand All @@ -28,7 +30,8 @@ fn main() {
ref mut foo
if {
(|| { let bar = foo; bar.take() })();
//~^ ERROR cannot move out of borrowed content [E0507]
//[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."),
Expand Down
@@ -0,0 +1,9 @@
error[E0507]: cannot move out of borrowed content
--> $DIR/borrowck-feature-nll-overrides-migrate.rs:32: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`.
@@ -1,5 +1,5 @@
warning[E0507]: cannot move out of borrowed content
--> $DIR/borrowck-migrate-to-nll.rs:26:17
--> $DIR/borrowck-migrate-to-nll.rs:35:17
|
LL | (|| { let bar = foo; bar.take() })();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
Expand All @@ -9,7 +9,7 @@ LL | (|| { let bar = foo; bar.take() })();
This warning will become a hard error in the future.

warning[E0507]: cannot move out of `foo`, as it is immutable for the pattern guard
--> $DIR/borrowck-migrate-to-nll.rs:26:17
--> $DIR/borrowck-migrate-to-nll.rs:35:17
|
LL | (|| { let bar = foo; bar.take() })();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
13 changes: 11 additions & 2 deletions src/test/ui/borrowck/borrowck-migrate-to-nll.rs
Expand Up @@ -15,8 +15,17 @@
// Therefore, for backwards-compatiblity, under borrowck=migrate the
// NLL checks will be emitted as *warnings*.

// compile-flags: -Z borrowck=migrate
// run-pass
// NLL mode makes this compile-fail; we cannot currently encode a
// test that is run-pass or compile-fail based on compare-mode. So
// just ignore it instead:

// ignore-compare-mode-nll

// revisions: zflag edition
//[zflag]compile-flags: -Z borrowck=migrate
//[edition]compile-flags: --edition 2018
//[zflag] run-pass
//[edition] run-pass

fn main() {
match Some(&4) {
Expand Down
24 changes: 24 additions & 0 deletions src/test/ui/borrowck/borrowck-migrate-to-nll.zflag.stderr
@@ -0,0 +1,24 @@
warning[E0507]: cannot move out of borrowed content
--> $DIR/borrowck-migrate-to-nll.rs:35:17
|
LL | (|| { let bar = foo; bar.take() })();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
|
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
It represents potential unsoundness in your code.
This warning will become a hard error in the future.

warning[E0507]: cannot move out of `foo`, as it is immutable for the pattern guard
--> $DIR/borrowck-migrate-to-nll.rs:35:17
|
LL | (|| { let bar = foo; bar.take() })();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| cannot move out of `foo`, as it is immutable for the pattern guard
| cannot move
|
= note: variables bound in patterns are immutable until the end of the pattern guard
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
It represents potential unsoundness in your code.
This warning will become a hard error in the future.

0 comments on commit 9f05f29

Please sign in to comment.