recover_intersection_pat: adjust wording

This commit is contained in:
Mazdak Farrokhzad 2019-10-14 18:02:49 +02:00
parent 72ad8f716b
commit 3a9f8deb1d
3 changed files with 13 additions and 13 deletions

View File

@ -417,14 +417,14 @@ impl<'a> Parser<'a> {
*sub = Some(lhs);
self.struct_span_err(sp, "pattern on wrong side of `@`")
.span_label(lhs_span, "pattern on the left, should be to the right")
.span_label(rhs.span, "binding on the right, should be to the left")
.span_label(lhs_span, "pattern on the left, should be on the right")
.span_label(rhs.span, "binding on the right, should be on the left")
.span_suggestion(sp, "switch the order", pprust::pat_to_string(&rhs), applicability)
.emit();
} else {
// The special case above doesn't apply so we may have e.g. `A(x) @ B(y)`.
rhs.kind = PatKind::Wild;
self.struct_span_err(sp, "left-hand side of `@` must be a binding pattern")
self.struct_span_err(sp, "left-hand side of `@` must be a binding")
.span_label(lhs.span, "interpreted as a pattern, not a binding")
.span_label(rhs.span, "also a pattern")
.note("bindings are `x`, `mut x`, `ref x`, and `ref mut x`")

View File

@ -12,8 +12,8 @@ fn main() {
match s {
Some(x) @ y => {}
//~^ ERROR pattern on wrong side of `@`
//~| pattern on the left, should be to the right
//~| binding on the right, should be to the left
//~| pattern on the left, should be on the right
//~| binding on the right, should be on the left
//~| HELP switch the order
//~| SUGGESTION y@Some(x)
_ => {}
@ -21,7 +21,7 @@ fn main() {
match s {
Some(x) @ Some(y) => {}
//~^ ERROR left-hand side of `@` must be a binding pattern
//~^ ERROR left-hand side of `@` must be a binding
//~| interpreted as a pattern, not a binding
//~| also a pattern
//~| NOTE bindings are `x`, `mut x`, `ref x`, and `ref mut x`
@ -31,8 +31,8 @@ fn main() {
match 2 {
1 ..= 5 @ e => {}
//~^ ERROR pattern on wrong side of `@`
//~| pattern on the left, should be to the right
//~| binding on the right, should be to the left
//~| pattern on the left, should be on the right
//~| binding on the right, should be on the left
//~| HELP switch the order
//~| SUGGESTION e@1 ..=5
_ => {}

View File

@ -4,11 +4,11 @@ error: pattern on wrong side of `@`
LL | Some(x) @ y => {}
| -------^^^-
| | |
| | binding on the right, should be to the left
| pattern on the left, should be to the right
| | binding on the right, should be on the left
| pattern on the left, should be on the right
| help: switch the order: `y@Some(x)`
error: left-hand side of `@` must be a binding pattern
error: left-hand side of `@` must be a binding
--> $DIR/intersection-patterns.rs:23:9
|
LL | Some(x) @ Some(y) => {}
@ -25,8 +25,8 @@ error: pattern on wrong side of `@`
LL | 1 ..= 5 @ e => {}
| -------^^^-
| | |
| | binding on the right, should be to the left
| pattern on the left, should be to the right
| | binding on the right, should be on the left
| pattern on the left, should be on the right
| help: switch the order: `e@1 ..=5`
error: aborting due to 3 previous errors