Skip to content

Commit 194282b

Browse files
committed
borrowck-migrate-to-nll: use #38899 for testing.
1 parent a5a039d commit 194282b

File tree

3 files changed

+32
-30
lines changed

3 files changed

+32
-30
lines changed

src/test/ui/borrowck/borrowck-migrate-to-nll.edition.stderr

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
warning[E0507]: cannot move out of `foo` in pattern guard
2-
--> $DIR/borrowck-migrate-to-nll.rs:26:18
1+
warning[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
2+
--> $DIR/borrowck-migrate-to-nll.rs:28:21
33
|
4-
LL | (|| { let bar = foo; bar.take() })();
5-
| ^^ ---
6-
| | |
7-
| | move occurs because `foo` has type `&mut std::option::Option<&i32>`, which does not implement the `Copy` trait
8-
| | move occurs due to use in closure
9-
| move out of `foo` occurs here
4+
LL | let x = &mut block;
5+
| ---------- mutable borrow occurs here
6+
LL | let p: &'a u8 = &*block.current;
7+
| ^^^^^^^^^^^^^^^ immutable borrow occurs here
8+
LL | // (use `x` and `p` so enabling NLL doesn't assign overly short lifetimes)
9+
LL | drop(x);
10+
| - mutable borrow later used here
1011
|
11-
= note: variables bound in patterns cannot be moved from until after the end of the pattern guard
1212
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
1313
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
1414
= note: for more information, try `rustc --explain E0729`
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This is a test of the borrowck migrate mode. It leverages #27282, a
1+
// This is a test of the borrowck migrate mode. It leverages #38899, a
22
// bug that is fixed by NLL: this code is (unsoundly) accepted by
33
// AST-borrowck, but is correctly rejected by the NLL borrowck.
44
//
@@ -18,15 +18,17 @@
1818
//[zflag] run-pass
1919
//[edition] run-pass
2020

21-
fn main() {
22-
match Some(&4) {
23-
None => {},
24-
ref mut foo
25-
if {
26-
(|| { let bar = foo; bar.take() })();
27-
false
28-
} => {},
29-
Some(ref _s) => println!("Note this arm is bogus; the `Some` became `None` in the guard."),
30-
_ => println!("Here is some supposedly unreachable code."),
31-
}
21+
pub struct Block<'a> {
22+
current: &'a u8,
23+
unrelated: &'a u8,
3224
}
25+
26+
fn bump<'a>(mut block: &mut Block<'a>) {
27+
let x = &mut block;
28+
let p: &'a u8 = &*block.current;
29+
// (use `x` and `p` so enabling NLL doesn't assign overly short lifetimes)
30+
drop(x);
31+
drop(p);
32+
}
33+
34+
fn main() {}

src/test/ui/borrowck/borrowck-migrate-to-nll.zflag.stderr

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
warning[E0507]: cannot move out of `foo` in pattern guard
2-
--> $DIR/borrowck-migrate-to-nll.rs:26:18
1+
warning[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
2+
--> $DIR/borrowck-migrate-to-nll.rs:28:21
33
|
4-
LL | (|| { let bar = foo; bar.take() })();
5-
| ^^ ---
6-
| | |
7-
| | move occurs because `foo` has type `&mut std::option::Option<&i32>`, which does not implement the `Copy` trait
8-
| | move occurs due to use in closure
9-
| move out of `foo` occurs here
4+
LL | let x = &mut block;
5+
| ---------- mutable borrow occurs here
6+
LL | let p: &'a u8 = &*block.current;
7+
| ^^^^^^^^^^^^^^^ immutable borrow occurs here
8+
LL | // (use `x` and `p` so enabling NLL doesn't assign overly short lifetimes)
9+
LL | drop(x);
10+
| - mutable borrow later used here
1011
|
11-
= note: variables bound in patterns cannot be moved from until after the end of the pattern guard
1212
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
1313
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
1414
= note: for more information, try `rustc --explain E0729`

0 commit comments

Comments
 (0)