Skip to content

Commit 3a9f8de

Browse files
committed
recover_intersection_pat: adjust wording
1 parent 72ad8f7 commit 3a9f8de

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/libsyntax/parse/parser/pat.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,14 @@ impl<'a> Parser<'a> {
417417
*sub = Some(lhs);
418418

419419
self.struct_span_err(sp, "pattern on wrong side of `@`")
420-
.span_label(lhs_span, "pattern on the left, should be to the right")
421-
.span_label(rhs.span, "binding on the right, should be to the left")
420+
.span_label(lhs_span, "pattern on the left, should be on the right")
421+
.span_label(rhs.span, "binding on the right, should be on the left")
422422
.span_suggestion(sp, "switch the order", pprust::pat_to_string(&rhs), applicability)
423423
.emit();
424424
} else {
425425
// The special case above doesn't apply so we may have e.g. `A(x) @ B(y)`.
426426
rhs.kind = PatKind::Wild;
427-
self.struct_span_err(sp, "left-hand side of `@` must be a binding pattern")
427+
self.struct_span_err(sp, "left-hand side of `@` must be a binding")
428428
.span_label(lhs.span, "interpreted as a pattern, not a binding")
429429
.span_label(rhs.span, "also a pattern")
430430
.note("bindings are `x`, `mut x`, `ref x`, and `ref mut x`")

src/test/ui/parser/intersection-patterns.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ fn main() {
1212
match s {
1313
Some(x) @ y => {}
1414
//~^ ERROR pattern on wrong side of `@`
15-
//~| pattern on the left, should be to the right
16-
//~| binding on the right, should be to the left
15+
//~| pattern on the left, should be on the right
16+
//~| binding on the right, should be on the left
1717
//~| HELP switch the order
1818
//~| SUGGESTION y@Some(x)
1919
_ => {}
2020
}
2121

2222
match s {
2323
Some(x) @ Some(y) => {}
24-
//~^ ERROR left-hand side of `@` must be a binding pattern
24+
//~^ ERROR left-hand side of `@` must be a binding
2525
//~| interpreted as a pattern, not a binding
2626
//~| also a pattern
2727
//~| NOTE bindings are `x`, `mut x`, `ref x`, and `ref mut x`
@@ -31,8 +31,8 @@ fn main() {
3131
match 2 {
3232
1 ..= 5 @ e => {}
3333
//~^ ERROR pattern on wrong side of `@`
34-
//~| pattern on the left, should be to the right
35-
//~| binding on the right, should be to the left
34+
//~| pattern on the left, should be on the right
35+
//~| binding on the right, should be on the left
3636
//~| HELP switch the order
3737
//~| SUGGESTION e@1 ..=5
3838
_ => {}

src/test/ui/parser/intersection-patterns.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ error: pattern on wrong side of `@`
44
LL | Some(x) @ y => {}
55
| -------^^^-
66
| | |
7-
| | binding on the right, should be to the left
8-
| pattern on the left, should be to the right
7+
| | binding on the right, should be on the left
8+
| pattern on the left, should be on the right
99
| help: switch the order: `y@Some(x)`
1010

11-
error: left-hand side of `@` must be a binding pattern
11+
error: left-hand side of `@` must be a binding
1212
--> $DIR/intersection-patterns.rs:23:9
1313
|
1414
LL | Some(x) @ Some(y) => {}
@@ -25,8 +25,8 @@ error: pattern on wrong side of `@`
2525
LL | 1 ..= 5 @ e => {}
2626
| -------^^^-
2727
| | |
28-
| | binding on the right, should be to the left
29-
| pattern on the left, should be to the right
28+
| | binding on the right, should be on the left
29+
| pattern on the left, should be on the right
3030
| help: switch the order: `e@1 ..=5`
3131

3232
error: aborting due to 3 previous errors

0 commit comments

Comments
 (0)