Skip to content

Commit c4bf275

Browse files
committed
Remove 'feature(nll)' from bind_by_move_pattern_guards tests.
1 parent f64b66a commit c4bf275

20 files changed

+71
-68
lines changed

src/librustc_mir/error_codes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1989,7 +1989,7 @@ When matching on a variable it cannot be mutated in the match guards, as this
19891989
could cause the match to be non-exhaustive:
19901990
19911991
```compile_fail,E0510
1992-
#![feature(nll, bind_by_move_pattern_guards)]
1992+
#![feature(bind_by_move_pattern_guards)]
19931993
let mut x = Some(0);
19941994
match x {
19951995
None => (),

src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
// reject it. But I want to make sure that we continue to reject it
66
// (under NLL) even when that conservaive check goes away.
77

8-
98
#![feature(bind_by_move_pattern_guards)]
10-
#![feature(nll)]
119

1210
fn main() {
1311
let mut b = &mut true;

src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0596]: cannot borrow `r` as mutable, as it is immutable for the pattern guard
2-
--> $DIR/issue-27282-reborrow-ref-mut-in-guard.rs:16:25
2+
--> $DIR/issue-27282-reborrow-ref-mut-in-guard.rs:14:25
33
|
44
LL | ref mut r if { (|| { let bar = &mut *r; **bar = false; })();
55
| ^^ - mutable borrow occurs due to use of `r` in closure

src/test/ui/match/match-ref-mut-stability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
// run-pass
55

6-
#![feature(nll, bind_by_move_pattern_guards)]
6+
#![feature(bind_by_move_pattern_guards)]
77

88
// Test that z always point to the same temporary.
99
fn referent_stability() {

src/test/ui/nll/match-cfg-fake-edges.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Test that we have enough false edges to avoid exposing the exact matching
22
// algorithm in borrow checking.
33

4-
#![feature(nll, bind_by_move_pattern_guards)]
4+
#![feature(bind_by_move_pattern_guards)]
55

66
fn guard_always_precedes_arm(y: i32) {
77
let mut x;
@@ -41,18 +41,4 @@ fn guard_may_be_taken(y: bool) {
4141
};
4242
}
4343

44-
fn all_previous_tests_may_be_done(y: &mut (bool, bool)) {
45-
let r = &mut y.1;
46-
// We don't actually test y.1 to select the second arm, but we don't want
47-
// borrowck results to be based on the order we match patterns.
48-
match y {
49-
(false, true) => 1, //~ ERROR cannot use `y.1` because it was mutably borrowed
50-
(true, _) => {
51-
r;
52-
2
53-
}
54-
(false, _) => 3,
55-
};
56-
}
57-
5844
fn main() {}

src/test/ui/nll/match-cfg-fake-edges.stderr

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,7 @@ LL | true => {
1616
LL | x;
1717
| ^ value used here after move
1818

19-
error[E0503]: cannot use `y.1` because it was mutably borrowed
20-
--> $DIR/match-cfg-fake-edges.rs:49:17
21-
|
22-
LL | let r = &mut y.1;
23-
| -------- borrow of `y.1` occurs here
24-
...
25-
LL | (false, true) => 1,
26-
| ^^^^ use of borrowed `y.1`
27-
LL | (true, _) => {
28-
LL | r;
29-
| - borrow later used here
30-
31-
error: aborting due to 3 previous errors
19+
error: aborting due to 2 previous errors
3220

33-
Some errors have detailed explanations: E0381, E0382, E0503.
21+
Some errors have detailed explanations: E0381, E0382.
3422
For more information about an error, try `rustc --explain E0381`.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Test that we have enough false edges to avoid exposing the exact matching
2+
// algorithm in borrow checking.
3+
4+
#![feature(nll)]
5+
6+
fn all_previous_tests_may_be_done(y: &mut (bool, bool)) {
7+
let r = &mut y.1;
8+
// We don't actually test y.1 to select the second arm, but we don't want
9+
// borrowck results to be based on the order we match patterns.
10+
match y {
11+
(false, true) => 1, //~ ERROR cannot use `y.1` because it was mutably borrowed
12+
(true, _) => {
13+
r;
14+
2
15+
}
16+
(false, _) => 3,
17+
};
18+
}
19+
20+
fn main() {}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0503]: cannot use `y.1` because it was mutably borrowed
2+
--> $DIR/match-cfg-fake-edges2.rs:11:17
3+
|
4+
LL | let r = &mut y.1;
5+
| -------- borrow of `y.1` occurs here
6+
...
7+
LL | (false, true) => 1,
8+
| ^^^^ use of borrowed `y.1`
9+
LL | (true, _) => {
10+
LL | r;
11+
| - borrow later used here
12+
13+
error: aborting due to previous error
14+
15+
For more information about this error, try `rustc --explain E0503`.

src/test/ui/nll/match-guards-partially-borrow.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
// Test that we don't allow mutating the value being matched on in a way that
66
// changes which patterns it matches, until we have chosen an arm.
77

8-
98
#![feature(bind_by_move_pattern_guards)]
10-
#![feature(nll)]
119

1210
fn ok_mutation_in_guard(mut q: i32) {
1311
match q {

src/test/ui/nll/match-guards-partially-borrow.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0510]: cannot assign `q` in match guard
2-
--> $DIR/match-guards-partially-borrow.rs:59:13
2+
--> $DIR/match-guards-partially-borrow.rs:57:13
33
|
44
LL | match q {
55
| - value is immutable in match guard
@@ -8,7 +8,7 @@ LL | q = true;
88
| ^^^^^^^^ cannot assign
99

1010
error[E0510]: cannot assign `r` in match guard
11-
--> $DIR/match-guards-partially-borrow.rs:71:13
11+
--> $DIR/match-guards-partially-borrow.rs:69:13
1212
|
1313
LL | match r {
1414
| - value is immutable in match guard
@@ -17,7 +17,7 @@ LL | r = true;
1717
| ^^^^^^^^ cannot assign
1818

1919
error[E0510]: cannot assign `t` in match guard
20-
--> $DIR/match-guards-partially-borrow.rs:95:13
20+
--> $DIR/match-guards-partially-borrow.rs:93:13
2121
|
2222
LL | match t {
2323
| - value is immutable in match guard
@@ -26,7 +26,7 @@ LL | t = true;
2626
| ^^^^^^^^ cannot assign
2727

2828
error[E0510]: cannot mutably borrow `x.0` in match guard
29-
--> $DIR/match-guards-partially-borrow.rs:109:22
29+
--> $DIR/match-guards-partially-borrow.rs:107:22
3030
|
3131
LL | match x {
3232
| - value is immutable in match guard
@@ -35,7 +35,7 @@ LL | Some(ref mut r) => *r = None,
3535
| ^^^^^^^^^ cannot mutably borrow
3636

3737
error[E0506]: cannot assign to `t` because it is borrowed
38-
--> $DIR/match-guards-partially-borrow.rs:121:13
38+
--> $DIR/match-guards-partially-borrow.rs:119:13
3939
|
4040
LL | s if {
4141
| - borrow of `t` occurs here
@@ -46,7 +46,7 @@ LL | } => (), // What value should `s` have in the arm?
4646
| - borrow later used here
4747

4848
error[E0510]: cannot assign `y` in match guard
49-
--> $DIR/match-guards-partially-borrow.rs:132:13
49+
--> $DIR/match-guards-partially-borrow.rs:130:13
5050
|
5151
LL | match *y {
5252
| -- value is immutable in match guard
@@ -55,7 +55,7 @@ LL | y = &true;
5555
| ^^^^^^^^^ cannot assign
5656

5757
error[E0510]: cannot assign `z` in match guard
58-
--> $DIR/match-guards-partially-borrow.rs:143:13
58+
--> $DIR/match-guards-partially-borrow.rs:141:13
5959
|
6060
LL | match z {
6161
| - value is immutable in match guard
@@ -64,7 +64,7 @@ LL | z = &true;
6464
| ^^^^^^^^^ cannot assign
6565

6666
error[E0510]: cannot assign `a` in match guard
67-
--> $DIR/match-guards-partially-borrow.rs:155:13
67+
--> $DIR/match-guards-partially-borrow.rs:153:13
6868
|
6969
LL | match a {
7070
| - value is immutable in match guard
@@ -73,7 +73,7 @@ LL | a = &true;
7373
| ^^^^^^^^^ cannot assign
7474

7575
error[E0510]: cannot assign `b` in match guard
76-
--> $DIR/match-guards-partially-borrow.rs:166:13
76+
--> $DIR/match-guards-partially-borrow.rs:164:13
7777
|
7878
LL | match b {
7979
| - value is immutable in match guard

src/test/ui/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// rust-lang/rust#2329), that starts passing with this feature in
33
// place.
44

5-
// build-pass (FIXME(62277): could be check-pass?)
5+
// run-pass
66

77
#![feature(bind_by_move_pattern_guards)]
88

@@ -12,6 +12,7 @@ fn main() {
1212
let (tx, rx) = channel();
1313
let x = Some(rx);
1414
tx.send(false);
15+
tx.send(false);
1516
match x {
1617
Some(z) if z.recv().unwrap() => { panic!() },
1718
Some(z) => { assert!(!z.recv().unwrap()); },

src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2015.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: compilation successful
2-
--> $DIR/feature-gate.rs:41:1
2+
--> $DIR/feature-gate.rs:36:1
33
|
44
LL | / fn main() {
55
LL | | foo(107)

src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2018.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: compilation successful
2-
--> $DIR/feature-gate.rs:41:1
2+
--> $DIR/feature-gate.rs:36:1
33
|
44
LL | / fn main() {
55
LL | | foo(107)

src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.no_gate.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0008]: cannot bind by-move into a pattern guard
2-
--> $DIR/feature-gate.rs:33:16
2+
--> $DIR/feature-gate.rs:28:16
33
|
44
LL | A { a: v } if *v == 42 => v,
55
| ^ moves value into pattern guard

src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
// gate-test-bind_by_move_pattern_guards
88

9-
// revisions: no_gate gate_and_2015 gate_and_2018 gate_and_znll gate_and_feature_nll
9+
// revisions: no_gate gate_and_2015 gate_and_2018
1010

1111
// (We're already testing NLL behavior quite explicitly, no need for compare-mode=nll.)
1212
// ignore-compare-mode-nll
@@ -15,14 +15,9 @@
1515

1616
#![cfg_attr(gate_and_2015, feature(bind_by_move_pattern_guards))]
1717
#![cfg_attr(gate_and_2018, feature(bind_by_move_pattern_guards))]
18-
#![cfg_attr(gate_and_znll, feature(bind_by_move_pattern_guards))]
19-
#![cfg_attr(gate_and_feature_nll, feature(bind_by_move_pattern_guards))]
20-
21-
#![cfg_attr(gate_and_feature_nll, feature(nll))]
2218

2319
//[gate_and_2015] edition:2015
2420
//[gate_and_2018] edition:2018
25-
//[gate_and_znll] compile-flags: -Z borrowck=mir
2621

2722
struct A { a: Box<i32> }
2823

@@ -43,5 +38,3 @@ fn main() {
4338
}
4439
//[gate_and_2015]~^^^ ERROR compilation successful
4540
//[gate_and_2018]~^^^^ ERROR compilation successful
46-
//[gate_and_znll]~^^^^^ ERROR compilation successful
47-
//[gate_and_feature_nll]~^^^^^^ ERROR compilation successful
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,45 @@
11
#![feature(bind_by_move_pattern_guards)]
22

3-
// build-pass (FIXME(62277): could be check-pass?)
3+
// run-pass
44

55
struct A { a: Box<i32> }
66

77
impl A {
88
fn get(&self) -> i32 { *self.a }
99
}
1010

11-
fn foo(n: i32) {
11+
fn foo(n: i32) -> i32 {
1212
let x = A { a: Box::new(n) };
1313
let y = match x {
1414
A { a: v } if *v == 42 => v,
1515
_ => Box::new(0),
1616
};
17+
*y
1718
}
1819

19-
fn bar(n: i32) {
20+
fn bar(n: i32) -> i32 {
2021
let x = A { a: Box::new(n) };
2122
let y = match x {
2223
A { a: v } if x.get() == 42 => v,
2324
_ => Box::new(0),
2425
};
26+
*y
2527
}
2628

27-
fn baz(n: i32) {
29+
fn baz(n: i32) -> i32 {
2830
let x = A { a: Box::new(n) };
2931
let y = match x {
3032
A { a: v } if *v.clone() == 42 => v,
3133
_ => Box::new(0),
3234
};
35+
*y
3336
}
3437

3538
fn main() {
36-
foo(107);
37-
bar(107);
38-
baz(107);
39+
assert_eq!(foo(107), 0);
40+
assert_eq!(foo(42), 42);
41+
assert_eq!(bar(107), 0);
42+
assert_eq!(bar(42), 42);
43+
assert_eq!(baz(107), 0);
44+
assert_eq!(baz(42), 42);
3945
}

src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(nll)]
21
#![feature(bind_by_move_pattern_guards)]
32

43
enum VecWrapper { A(Vec<i32>) }

src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0507]: cannot move out of `v` in pattern guard
2-
--> $DIR/rfc-reject-double-move-across-arms.rs:8:36
2+
--> $DIR/rfc-reject-double-move-across-arms.rs:7:36
33
|
44
LL | VecWrapper::A(v) if { drop(v); false } => 1,
55
| ^ move occurs because `v` has type `std::vec::Vec<i32>`, which does not implement the `Copy` trait

src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(nll)]
21
#![feature(bind_by_move_pattern_guards)]
32

43
struct A { a: Box<i32> }

src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0507]: cannot move out of `v` in pattern guard
2-
--> $DIR/rfc-reject-double-move-in-first-arm.rs:9:30
2+
--> $DIR/rfc-reject-double-move-in-first-arm.rs:8:30
33
|
44
LL | A { a: v } if { drop(v); true } => v,
55
| ^ move occurs because `v` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait

0 commit comments

Comments
 (0)