Clarify error message and remove pretty printing in help suggestions.
This commit is contained in:
parent
8a83c8f64f
commit
7879099ad3
@ -1253,17 +1253,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
self.tcx.sess,
|
||||
pat.span,
|
||||
E0769,
|
||||
"tuple variant `{}` uses a bare index in a struct pattern",
|
||||
"tuple variant `{}` written as struct variant",
|
||||
path
|
||||
);
|
||||
err.span_suggestion(
|
||||
pat.span,
|
||||
qpath.span().shrink_to_hi().until(pat.span),
|
||||
"use the tuple variant pattern syntax instead",
|
||||
format!(
|
||||
"{}({})",
|
||||
path,
|
||||
self.get_suggested_tuple_struct_pattern(fields, variant)
|
||||
),
|
||||
format!("({})", self.get_suggested_tuple_struct_pattern(fields, variant)),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
return Some(err);
|
||||
@ -1421,9 +1417,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
)
|
||||
};
|
||||
err.span_suggestion(
|
||||
pat.span,
|
||||
qpath.span().shrink_to_hi().until(pat.span),
|
||||
"use the tuple variant pattern syntax instead",
|
||||
format!("{}({})", path, sugg),
|
||||
format!("({})", sugg),
|
||||
appl,
|
||||
);
|
||||
return Some(err);
|
||||
|
@ -2,7 +2,9 @@ error[E0769]: tuple variant `MyOption::MySome` written as struct variant
|
||||
--> $DIR/issue-17800.rs:8:9
|
||||
|
|
||||
LL | MyOption::MySome { x: 42 } => (),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the tuple variant pattern syntax instead: `MyOption::MySome(42)`
|
||||
| ----------------^^^^^^^^^^
|
||||
| |
|
||||
| help: use the tuple variant pattern syntax instead: `(42)`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -2,7 +2,9 @@ error[E0769]: tuple variant `S` written as struct variant
|
||||
--> $DIR/missing-fields-in-struct-pattern.rs:4:12
|
||||
|
|
||||
LL | if let S { a, b, c, d } = S(1, 2, 3, 4) {
|
||||
| ^^^^^^^^^^^^^^^^ help: use the tuple variant pattern syntax instead: `S(a, b, c, d)`
|
||||
| -^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: use the tuple variant pattern syntax instead: `(a, b, c, d)`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -22,7 +22,9 @@ error[E0769]: tuple variant `Enum::Bar` written as struct variant
|
||||
--> $DIR/recover-from-bad-variant.rs:12:9
|
||||
|
|
||||
LL | Enum::Bar { a, b } => {}
|
||||
| ^^^^^^^^^^^^^^^^^^ help: use the tuple variant pattern syntax instead: `Enum::Bar(a, b)`
|
||||
| ---------^^^^^^^^^
|
||||
| |
|
||||
| help: use the tuple variant pattern syntax instead: `(a, b)`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
@ -6,7 +6,7 @@ fn main() {
|
||||
let x = E::S(1, 2.2);
|
||||
match x {
|
||||
E::S { 0, 1 } => {}
|
||||
//~^ ERROR tuple variant `E::S` uses a bare index in a struct pattern [E0769]
|
||||
//~^ ERROR tuple variant `E::S` written as struct variant [E0769]
|
||||
}
|
||||
let y = S(1, 2.2);
|
||||
match y {
|
||||
|
@ -1,14 +1,18 @@
|
||||
error[E0769]: tuple variant `E::S` uses a bare index in a struct pattern
|
||||
error[E0769]: tuple variant `E::S` written as struct variant
|
||||
--> $DIR/struct-tuple-field-names.rs:8:9
|
||||
|
|
||||
LL | E::S { 0, 1 } => {}
|
||||
| ^^^^^^^^^^^^^ help: use the tuple variant pattern syntax instead: `E::S(_, _)`
|
||||
| ----^^^^^^^^^
|
||||
| |
|
||||
| help: use the tuple variant pattern syntax instead: `(_, _)`
|
||||
|
||||
error[E0769]: tuple variant `S` written as struct variant
|
||||
--> $DIR/struct-tuple-field-names.rs:13:9
|
||||
|
|
||||
LL | S { } => {}
|
||||
| ^^^^^ help: use the tuple variant pattern syntax instead: `S(_, _)`
|
||||
| -^^^^
|
||||
| |
|
||||
| help: use the tuple variant pattern syntax instead: `(_, _)`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -2,7 +2,9 @@ error[E0769]: tuple variant `X::Y` written as struct variant
|
||||
--> $DIR/issue-41314.rs:7:9
|
||||
|
|
||||
LL | X::Y { number } => {}
|
||||
| ^^^^^^^^^^^^^^^ help: use the tuple variant pattern syntax instead: `X::Y(number)`
|
||||
| ----^^^^^^^^^^^
|
||||
| |
|
||||
| help: use the tuple variant pattern syntax instead: `(number)`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user