Fix suggestion span and move suggestions into new subwindow.
This commit is contained in:
parent
7879099ad3
commit
d8540ae5a9
|
@ -1256,8 +1256,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
"tuple variant `{}` written as struct variant",
|
||||
path
|
||||
);
|
||||
err.span_suggestion(
|
||||
qpath.span().shrink_to_hi().until(pat.span),
|
||||
err.span_suggestion_verbose(
|
||||
qpath.span().shrink_to_hi().to(pat.span.shrink_to_hi()),
|
||||
"use the tuple variant pattern syntax instead",
|
||||
format!("({})", self.get_suggested_tuple_struct_pattern(fields, variant)),
|
||||
Applicability::MaybeIncorrect,
|
||||
|
@ -1416,8 +1416,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
Applicability::MaybeIncorrect,
|
||||
)
|
||||
};
|
||||
err.span_suggestion(
|
||||
qpath.span().shrink_to_hi().until(pat.span),
|
||||
err.span_suggestion_verbose(
|
||||
qpath.span().shrink_to_hi().to(pat.span.shrink_to_hi()),
|
||||
"use the tuple variant pattern syntax instead",
|
||||
format!("({})", sugg),
|
||||
appl,
|
||||
|
|
|
@ -2,9 +2,12 @@ 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: `(42)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: use the tuple variant pattern syntax instead
|
||||
|
|
||||
LL | MyOption::MySome(42) => (),
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -2,9 +2,12 @@ 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: `(a, b, c, d)`
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: use the tuple variant pattern syntax instead
|
||||
|
|
||||
LL | if let S(a, b, c, d) = S(1, 2, 3, 4) {
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -22,9 +22,12 @@ 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: `(a, b)`
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: use the tuple variant pattern syntax instead
|
||||
|
|
||||
LL | Enum::Bar(a, b) => {}
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
@ -2,17 +2,23 @@ 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: `(_, _)`
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
help: use the tuple variant pattern syntax instead
|
||||
|
|
||||
LL | E::S(_, _) => {}
|
||||
| ^^^^^^
|
||||
|
||||
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: `(_, _)`
|
||||
| ^^^^^
|
||||
|
|
||||
help: use the tuple variant pattern syntax instead
|
||||
|
|
||||
LL | S(_, _) => {}
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -2,9 +2,12 @@ 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: `(number)`
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: use the tuple variant pattern syntax instead
|
||||
|
|
||||
LL | X::Y(number) => {}
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
Loading…
Reference in New Issue