Skip to content

Commit d984f12

Browse files
committed
move_ref_patterns: introduce tests
bindings_after_at: harden tests
1 parent 7af9ff3 commit d984f12

File tree

50 files changed

+1919
-541
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1919
-541
lines changed

src/test/ui/bind-by-move/bind-by-move-neither-can-live-while-the-other-survives-2.rs

-15
This file was deleted.

src/test/ui/bind-by-move/bind-by-move-neither-can-live-while-the-other-survives-2.stderr

-11
This file was deleted.

src/test/ui/bind-by-move/bind-by-move-neither-can-live-while-the-other-survives-3.rs

-18
This file was deleted.

src/test/ui/bind-by-move/bind-by-move-neither-can-live-while-the-other-survives-3.stderr

-11
This file was deleted.

src/test/ui/bind-by-move/bind-by-move-neither-can-live-while-the-other-survives-4.rs

-15
This file was deleted.

src/test/ui/bind-by-move/bind-by-move-neither-can-live-while-the-other-survives-4.stderr

-11
This file was deleted.

src/test/ui/drop/dynamic-drop-async.rs

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
// edition:2018
88
// ignore-wasm32-bare compiled with panic=abort by default
99

10+
#![feature(move_ref_pattern)]
11+
1012
#![allow(unused)]
1113

1214
use std::{
@@ -227,6 +229,12 @@ async fn subslice_pattern_reassign(a: Rc<Allocator>) {
227229
a.alloc().await;
228230
}
229231

232+
async fn move_ref_pattern(a: Rc<Allocator>) {
233+
let mut tup = (a.alloc().await, a.alloc().await, a.alloc().await, a.alloc().await);
234+
let (ref _a, ref mut _b, _c, mut _d) = tup;
235+
a.alloc().await;
236+
}
237+
230238
fn run_test<F, G>(cx: &mut Context<'_>, ref f: F)
231239
where
232240
F: Fn(Rc<Allocator>) -> G,
@@ -322,4 +330,6 @@ fn main() {
322330
run_test(context, |a| subslice_pattern_from_end_with_drop(a, false, true));
323331
run_test(context, |a| subslice_pattern_from_end_with_drop(a, false, false));
324332
run_test(context, |a| subslice_pattern_reassign(a));
333+
334+
run_test(context, |a| move_ref_pattern(a));
325335
}

src/test/ui/drop/dynamic-drop.rs

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// ignore-wasm32-bare compiled with panic=abort by default
33

44
#![feature(generators, generator_trait, untagged_unions)]
5+
#![feature(move_ref_pattern)]
56

67
#![allow(unused_assignments)]
78
#![allow(unused_variables)]
@@ -290,6 +291,11 @@ fn subslice_mixed_min_lengths(a: &Allocator, c: i32) {
290291
}
291292
}
292293

294+
fn move_ref_pattern(a: &Allocator) {
295+
let mut tup = (a.alloc(), a.alloc(), a.alloc(), a.alloc());
296+
let (ref _a, ref mut _b, _c, mut _d) = tup;
297+
}
298+
293299
fn panic_after_return(a: &Allocator) -> Ptr<'_> {
294300
// Panic in the drop of `p` or `q` can leak
295301
let exceptions = vec![8, 9];
@@ -453,6 +459,8 @@ fn main() {
453459
run_test(|a| subslice_mixed_min_lengths(a, 6));
454460
run_test(|a| subslice_mixed_min_lengths(a, 7));
455461

462+
run_test(|a| move_ref_pattern(a));
463+
456464
run_test(|a| {
457465
panic_after_return(a);
458466
});

src/test/ui/error-codes/E0009.rs

-9
This file was deleted.

src/test/ui/error-codes/E0009.stderr

-11
This file was deleted.

src/test/ui/issues/issue-53840.stderr

-20
This file was deleted.

src/test/ui/moves/move-out-of-slice-2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(slice_patterns, unsized_locals)]
1+
#![feature(unsized_locals)]
22

33
struct A;
44
#[derive(Clone, Copy)]

src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.rs

+14-9
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,38 @@
33
// where one side is by-ref and the other is by-move.
44

55
#![feature(bindings_after_at)]
6+
#![feature(move_ref_pattern)]
67

7-
struct X { x: () }
8+
struct X {
9+
x: (),
10+
}
811

912
fn main() {
1013
let x = Some(X { x: () });
1114
match x {
12-
Some(ref _y @ _z) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern
13-
None => panic!()
15+
Some(ref _y @ _z) => {} //~ ERROR cannot move out of `_y` because it is borrowed
16+
None => panic!(),
1417
}
1518

1619
let x = Some(X { x: () });
1720
match x {
18-
Some(_z @ ref _y) => { }, //~ ERROR cannot bind by-move with sub-bindings
21+
Some(_z @ ref _y) => {}
1922
//~^ ERROR borrow of moved value
20-
None => panic!()
23+
//~| ERROR borrow of moved value
24+
None => panic!(),
2125
}
2226

2327
let mut x = Some(X { x: () });
2428
match x {
25-
Some(ref mut _y @ _z) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern
26-
None => panic!()
29+
Some(ref mut _y @ _z) => {} //~ ERROR cannot move out of `_y` because it is borrowed
30+
None => panic!(),
2731
}
2832

2933
let mut x = Some(X { x: () });
3034
match x {
31-
Some(_z @ ref mut _y) => { }, //~ ERROR cannot bind by-move with sub-bindings
35+
Some(_z @ ref mut _y) => {}
3236
//~^ ERROR borrow of moved value
33-
None => panic!()
37+
//~| ERROR borrow of moved value
38+
None => panic!(),
3439
}
3540
}
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,45 @@
1-
error[E0009]: cannot bind by-move and by-ref in the same pattern
2-
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:12:23
1+
error: cannot move out of `_y` because it is borrowed
2+
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:15:14
33
|
4-
LL | Some(ref _y @ _z) => { },
5-
| ---------^^
4+
LL | Some(ref _y @ _z) => {}
5+
| ------^^^--
66
| | |
7-
| | by-move pattern here
8-
| by-ref pattern here
7+
| | move out of `_y` occurs here
8+
| borrow of `_y` occurs here
99

10-
error[E0007]: cannot bind by-move with sub-bindings
11-
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:18:14
10+
error: borrow of moved value: `_z`
11+
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:21:14
1212
|
13-
LL | Some(_z @ ref _y) => { },
14-
| ^^^^^^^^^^^ binds an already bound by-move value by moving it
13+
LL | Some(_z @ ref _y) => {}
14+
| --^^^------
15+
| | |
16+
| | value borrowed here after move
17+
| value moved here
18+
| move occurs because `_z` has type `X` which does implement the `Copy` trait
1519

16-
error[E0009]: cannot bind by-move and by-ref in the same pattern
17-
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:25:27
20+
error: cannot move out of `_y` because it is borrowed
21+
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:29:14
1822
|
19-
LL | Some(ref mut _y @ _z) => { },
20-
| -------------^^
23+
LL | Some(ref mut _y @ _z) => {}
24+
| ----------^^^--
2125
| | |
22-
| | by-move pattern here
23-
| by-ref pattern here
26+
| | move out of `_y` occurs here
27+
| borrow of `_y` occurs here
2428

25-
error[E0007]: cannot bind by-move with sub-bindings
26-
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:31:14
29+
error: borrow of moved value: `_z`
30+
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:35:14
2731
|
28-
LL | Some(_z @ ref mut _y) => { },
29-
| ^^^^^^^^^^^^^^^ binds an already bound by-move value by moving it
32+
LL | Some(_z @ ref mut _y) => {}
33+
| --^^^----------
34+
| | |
35+
| | value borrowed here after move
36+
| value moved here
37+
| move occurs because `_z` has type `X` which does implement the `Copy` trait
3038

3139
error[E0382]: borrow of moved value
32-
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:18:19
40+
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:21:19
3341
|
34-
LL | Some(_z @ ref _y) => { },
42+
LL | Some(_z @ ref _y) => {}
3543
| -----^^^^^^
3644
| | |
3745
| | value borrowed here after move
@@ -40,9 +48,9 @@ LL | Some(_z @ ref _y) => { },
4048
= note: move occurs because value has type `X`, which does not implement the `Copy` trait
4149

4250
error[E0382]: borrow of moved value
43-
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:31:19
51+
--> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:35:19
4452
|
45-
LL | Some(_z @ ref mut _y) => { },
53+
LL | Some(_z @ ref mut _y) => {}
4654
| -----^^^^^^^^^^
4755
| | |
4856
| | value borrowed here after move
@@ -52,5 +60,4 @@ LL | Some(_z @ ref mut _y) => { },
5260

5361
error: aborting due to 6 previous errors
5462

55-
Some errors have detailed explanations: E0007, E0009, E0382.
56-
For more information about an error, try `rustc --explain E0007`.
63+
For more information about this error, try `rustc --explain E0382`.
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// See issue #12534.
22

33
#![feature(bindings_after_at)]
4+
#![feature(move_ref_pattern)]
45

56
fn main() {}
67

78
struct A(Box<u8>);
89

910
fn f(a @ A(u): A) -> Box<u8> {
10-
//~^ ERROR cannot bind by-move with sub-bindings
11-
//~| ERROR use of moved value
11+
//~^ ERROR use of moved value
1212
drop(a);
1313
u
1414
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
error[E0007]: cannot bind by-move with sub-bindings
2-
--> $DIR/bind-by-move-no-subbindings-fun-param.rs:9:6
3-
|
4-
LL | fn f(a @ A(u): A) -> Box<u8> {
5-
| ^^^^^^^^ binds an already bound by-move value by moving it
6-
71
error[E0382]: use of moved value
8-
--> $DIR/bind-by-move-no-subbindings-fun-param.rs:9:12
2+
--> $DIR/bind-by-move-no-subbindings-fun-param.rs:10:12
93
|
104
LL | fn f(a @ A(u): A) -> Box<u8> {
115
| ------^-
@@ -14,7 +8,6 @@ LL | fn f(a @ A(u): A) -> Box<u8> {
148
| value moved here
159
| move occurs because value has type `A`, which does not implement the `Copy` trait
1610

17-
error: aborting due to 2 previous errors
11+
error: aborting due to previous error
1812

19-
Some errors have detailed explanations: E0007, E0382.
20-
For more information about an error, try `rustc --explain E0007`.
13+
For more information about this error, try `rustc --explain E0382`.

0 commit comments

Comments
 (0)