Skip to content

Commit 5b27aae

Browse files
committed
add comments to tests
1 parent 8b09607 commit 5b27aae

File tree

10 files changed

+89
-50
lines changed

10 files changed

+89
-50
lines changed

tests/ui/loop-match/break-to-block.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
// Test that a break without #[const_continue] still works as expected.
2+
13
//@ run-pass
24

5+
#![allow(incomplete_features)]
36
#![feature(loop_match)]
47

58
fn main() {

tests/ui/loop-match/drop-in-match-arm.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
// Test that dropping values works in match arms, which is nontrivial
2+
// because each match arm needs its own scope.
3+
14
//@ run-pass
25

6+
#![allow(incomplete_features)]
37
#![feature(loop_match)]
48

5-
// test that drops work in match arms (match arms need their own scope)
6-
79
fn main() {
810
assert_eq!(helper(), 1);
911
}

tests/ui/loop-match/integer-patterns.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
// Test that signed and unsigned integer patterns work with #[loop_match].
2+
13
//@ run-pass
24

5+
#![allow(incomplete_features)]
36
#![feature(loop_match)]
47

58
fn main() {
@@ -13,7 +16,6 @@ fn main() {
1316
#[const_continue]
1417
break 'blk 2;
1518
} else {
16-
// No drops allowed at this point
1719
#[const_continue]
1820
break 'blk 0;
1921
}
@@ -27,4 +29,5 @@ fn main() {
2729
}
2830
}
2931
}
32+
assert_eq!(state, 2);
3033
}

tests/ui/loop-match/invalid-attribute.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Checks that #[loop_match] and #[const_continue] attributes can be
22
// placed on expressions only.
33
//
4+
#![allow(incomplete_features)]
45
#![feature(loop_match)]
56
#![loop_match] //~ ERROR should be applied to a loop
67
#![const_continue] //~ ERROR should be applied to a break expression

tests/ui/loop-match/invalid-attribute.stderr

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `#[loop_match]` should be applied to a loop
2-
--> $DIR/invalid-attribute.rs:14:1
2+
--> $DIR/invalid-attribute.rs:15:1
33
|
44
LL | #[loop_match]
55
| ^^^^^^^^^^^^^
@@ -8,7 +8,7 @@ LL | struct S {
88
| -------- not a loop
99

1010
error: `#[const_continue]` should be applied to a break expression
11-
--> $DIR/invalid-attribute.rs:15:1
11+
--> $DIR/invalid-attribute.rs:16:1
1212
|
1313
LL | #[const_continue]
1414
| ^^^^^^^^^^^^^^^^^
@@ -17,7 +17,7 @@ LL | struct S {
1717
| -------- not a break expression
1818

1919
error: `#[loop_match]` should be applied to a loop
20-
--> $DIR/invalid-attribute.rs:28:1
20+
--> $DIR/invalid-attribute.rs:29:1
2121
|
2222
LL | #[loop_match]
2323
| ^^^^^^^^^^^^^
@@ -26,15 +26,15 @@ LL | extern "C" fn ok() {}
2626
| ------------------ not a loop
2727

2828
error: `#[const_continue]` should be applied to a break expression
29-
--> $DIR/invalid-attribute.rs:29:1
29+
--> $DIR/invalid-attribute.rs:30:1
3030
|
3131
LL | #[const_continue]
3232
| ^^^^^^^^^^^^^^^^^
3333
LL | extern "C" fn ok() {}
3434
| ------------------ not a break expression
3535

3636
error: `#[loop_match]` should be applied to a loop
37-
--> $DIR/invalid-attribute.rs:33:5
37+
--> $DIR/invalid-attribute.rs:34:5
3838
|
3939
LL | #[loop_match]
4040
| ^^^^^^^^^^^^^
@@ -43,15 +43,15 @@ LL | || {};
4343
| -- not a loop
4444

4545
error: `#[const_continue]` should be applied to a break expression
46-
--> $DIR/invalid-attribute.rs:34:5
46+
--> $DIR/invalid-attribute.rs:35:5
4747
|
4848
LL | #[const_continue]
4949
| ^^^^^^^^^^^^^^^^^
5050
LL | || {};
5151
| -- not a break expression
5252

5353
error: `#[loop_match]` should be applied to a loop
54-
--> $DIR/invalid-attribute.rs:38:9
54+
--> $DIR/invalid-attribute.rs:39:9
5555
|
5656
LL | #[loop_match]
5757
| ^^^^^^^^^^^^^
@@ -60,15 +60,15 @@ LL | 5
6060
| - not a loop
6161

6262
error: `#[const_continue]` should be applied to a break expression
63-
--> $DIR/invalid-attribute.rs:39:9
63+
--> $DIR/invalid-attribute.rs:40:9
6464
|
6565
LL | #[const_continue]
6666
| ^^^^^^^^^^^^^^^^^
6767
LL | 5
6868
| - not a break expression
6969

7070
error: `#[loop_match]` should be applied to a loop
71-
--> $DIR/invalid-attribute.rs:23:5
71+
--> $DIR/invalid-attribute.rs:24:5
7272
|
7373
LL | #[loop_match]
7474
| ^^^^^^^^^^^^^
@@ -77,15 +77,15 @@ LL | extern "C" fn invoke(&self);
7777
| ---------------------------- not a loop
7878

7979
error: `#[const_continue]` should be applied to a break expression
80-
--> $DIR/invalid-attribute.rs:24:5
80+
--> $DIR/invalid-attribute.rs:25:5
8181
|
8282
LL | #[const_continue]
8383
| ^^^^^^^^^^^^^^^^^
8484
LL | extern "C" fn invoke(&self);
8585
| ---------------------------- not a break expression
8686

8787
error: `#[loop_match]` should be applied to a loop
88-
--> $DIR/invalid-attribute.rs:9:5
88+
--> $DIR/invalid-attribute.rs:10:5
8989
|
9090
LL | #[loop_match]
9191
| ^^^^^^^^^^^^^
@@ -94,17 +94,18 @@ LL | fn f();
9494
| ------- not a loop
9595

9696
error: `#[const_continue]` should be applied to a break expression
97-
--> $DIR/invalid-attribute.rs:10:5
97+
--> $DIR/invalid-attribute.rs:11:5
9898
|
9999
LL | #[const_continue]
100100
| ^^^^^^^^^^^^^^^^^
101101
LL | fn f();
102102
| ------- not a break expression
103103

104104
error: `#[loop_match]` should be applied to a loop
105-
--> $DIR/invalid-attribute.rs:5:1
105+
--> $DIR/invalid-attribute.rs:6:1
106106
|
107-
LL | / #![feature(loop_match)]
107+
LL | / #![allow(incomplete_features)]
108+
LL | | #![feature(loop_match)]
108109
LL | | #![loop_match]
109110
| | ^^^^^^^^^^^^^^
110111
LL | | #![const_continue]
@@ -114,9 +115,10 @@ LL | | }
114115
| |_- not a loop
115116

116117
error: `#[const_continue]` should be applied to a break expression
117-
--> $DIR/invalid-attribute.rs:6:1
118+
--> $DIR/invalid-attribute.rs:7:1
118119
|
119-
LL | / #![feature(loop_match)]
120+
LL | / #![allow(incomplete_features)]
121+
LL | | #![feature(loop_match)]
120122
LL | | #![loop_match]
121123
LL | | #![const_continue]
122124
| | ^^^^^^^^^^^^^^^^^^

tests/ui/loop-match/invalid.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Test that a good error is emitted when #[loop_match] is applied to syntax it does not support.
2+
#![allow(incomplete_features)]
13
#![feature(loop_match)]
24
#![crate_type = "lib"]
35

@@ -13,7 +15,7 @@ fn invalid_update() {
1315
#[loop_match]
1416
loop {
1517
fake = 'blk: {
16-
//~^ ERROR: invalid update of the `loop_match` state
18+
//~^ ERROR invalid update of the `loop_match` state
1719
match state {
1820
_ => State::B,
1921
}
@@ -27,7 +29,7 @@ fn invalid_scrutinee() {
2729
loop {
2830
state = 'blk: {
2931
match State::A {
30-
//~^ ERROR: invalid match on `loop_match` state
32+
//~^ ERROR invalid match on `loop_match` state
3133
_ => State::B,
3234
}
3335
}
@@ -39,7 +41,7 @@ fn bad_statements_1() {
3941
#[loop_match]
4042
loop {
4143
1;
42-
//~^ ERROR: statements are not allowed in this position within a `loop_match`
44+
//~^ ERROR statements are not allowed in this position within a `loop_match`
4345
state = 'blk: {
4446
match State::A {
4547
_ => State::B,
@@ -54,7 +56,7 @@ fn bad_statements_2() {
5456
loop {
5557
state = 'blk: {
5658
1;
57-
//~^ ERROR: statements are not allowed in this position within a `loop_match`
59+
//~^ ERROR statements are not allowed in this position within a `loop_match`
5860
match State::A {
5961
_ => State::B,
6062
}
@@ -67,7 +69,7 @@ fn bad_rhs_1() {
6769
#[loop_match]
6870
loop {
6971
state = State::B
70-
//~^ ERROR: this expression must be a single `match` wrapped in a labelled block
72+
//~^ ERROR this expression must be a single `match` wrapped in a labeled block
7173
}
7274
}
7375

@@ -77,7 +79,7 @@ fn bad_rhs_2() {
7779
loop {
7880
state = 'blk: {
7981
State::B
80-
//~^ ERROR: this expression must be a single `match` wrapped in a labelled block
82+
//~^ ERROR this expression must be a single `match` wrapped in a labeled block
8183
}
8284
}
8385
}
@@ -87,7 +89,7 @@ fn bad_rhs_3() {
8789
#[loop_match]
8890
loop {
8991
state = 'blk: {
90-
//~^ ERROR: this expression must be a single `match` wrapped in a labelled block
92+
//~^ ERROR this expression must be a single `match` wrapped in a labeled block
9193
}
9294
}
9395
}
@@ -96,15 +98,15 @@ fn missing_assignment() {
9698
let state = State::A;
9799
#[loop_match]
98100
loop {
99-
() //~ ERROR: expected a single assignment expression
101+
() //~ ERROR expected a single assignment expression
100102
}
101103
}
102104

103105
fn empty_loop_body() {
104106
let state = State::A;
105107
#[loop_match]
106108
loop {
107-
//~^ ERROR: expected a single assignment expression
109+
//~^ ERROR expected a single assignment expression
108110
}
109111
}
110112

@@ -117,7 +119,7 @@ fn break_without_value() {
117119
State::A => {
118120
#[const_continue]
119121
break 'blk;
120-
//~^ ERROR: mismatched types
122+
//~^ ERROR mismatched types
121123
}
122124
_ => break 'a,
123125
}
@@ -134,7 +136,7 @@ fn break_without_value_unit() {
134136
() => {
135137
#[const_continue]
136138
break 'blk;
137-
//~^ ERROR: a `const_continue` must break to a label with a value
139+
//~^ ERROR a `const_continue` must break to a label with a value
138140
}
139141
}
140142
}

tests/ui/loop-match/invalid.stderr

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/invalid.rs:119:21
2+
--> $DIR/invalid.rs:121:21
33
|
44
LL | break 'blk;
55
| ^^^^^^^^^^ expected `State`, found `()`
@@ -10,7 +10,7 @@ LL | break 'blk /* value */;
1010
| +++++++++++
1111

1212
error: invalid update of the `loop_match` state
13-
--> $DIR/invalid.rs:15:9
13+
--> $DIR/invalid.rs:17:9
1414
|
1515
LL | fake = 'blk: {
1616
| ^^^^
@@ -19,39 +19,39 @@ LL | match state {
1919
| ----- the assignment must update this variable
2020

2121
error: invalid match on `loop_match` state
22-
--> $DIR/invalid.rs:29:19
22+
--> $DIR/invalid.rs:31:19
2323
|
2424
LL | match State::A {
2525
| ^^^^^^^^
2626
|
2727
= note: only matches on local variables are valid
2828

2929
error: statements are not allowed in this position within a `loop_match`
30-
--> $DIR/invalid.rs:41:9
30+
--> $DIR/invalid.rs:43:9
3131
|
3232
LL | 1;
3333
| ^^
3434

3535
error: statements are not allowed in this position within a `loop_match`
36-
--> $DIR/invalid.rs:56:13
36+
--> $DIR/invalid.rs:58:13
3737
|
3838
LL | 1;
3939
| ^^
4040

41-
error: this expression must be a single `match` wrapped in a labelled block
42-
--> $DIR/invalid.rs:69:17
41+
error: this expression must be a single `match` wrapped in a labeled block
42+
--> $DIR/invalid.rs:71:17
4343
|
4444
LL | state = State::B
4545
| ^^^^^^^^
4646

47-
error: this expression must be a single `match` wrapped in a labelled block
48-
--> $DIR/invalid.rs:79:13
47+
error: this expression must be a single `match` wrapped in a labeled block
48+
--> $DIR/invalid.rs:81:13
4949
|
5050
LL | State::B
5151
| ^^^^^^^^
5252

53-
error: this expression must be a single `match` wrapped in a labelled block
54-
--> $DIR/invalid.rs:89:17
53+
error: this expression must be a single `match` wrapped in a labeled block
54+
--> $DIR/invalid.rs:91:17
5555
|
5656
LL | state = 'blk: {
5757
| _________________^
@@ -60,13 +60,13 @@ LL | | }
6060
| |_________^
6161

6262
error: expected a single assignment expression
63-
--> $DIR/invalid.rs:99:9
63+
--> $DIR/invalid.rs:101:9
6464
|
6565
LL | ()
6666
| ^^
6767

6868
error: expected a single assignment expression
69-
--> $DIR/invalid.rs:106:10
69+
--> $DIR/invalid.rs:108:10
7070
|
7171
LL | loop {
7272
| __________^
@@ -75,7 +75,7 @@ LL | | }
7575
| |_____^
7676

7777
error: a `const_continue` must break to a label with a value
78-
--> $DIR/invalid.rs:136:21
78+
--> $DIR/invalid.rs:138:21
7979
|
8080
LL | break 'blk;
8181
| ^^^^^^^^^^

0 commit comments

Comments
 (0)