rust/src/test/ui/destructuring-assignment/tuple_struct_destructure_fail.stderr
Noah Lev 8a6501d288 Adjust spans
* Highlight the whole pattern if it has no fields
* Highlight the whole definition if it has no fields
* Only highlight the pattern name if the pattern is multi-line
* Determine whether a pattern is multi-line based on distance from name
  to last field, rather than first field
2021-08-25 14:40:06 -07:00

98 lines
3.5 KiB
Text

error: `..` can only be used once per tuple struct or variant pattern
--> $DIR/tuple_struct_destructure_fail.rs:25:27
|
LL | TupleStruct(a, .., b, ..) = TupleStruct(0, 1);
| -- ^^ can only be used once per tuple struct or variant pattern
| |
| previously used here
error: `..` can only be used once per tuple struct or variant pattern
--> $DIR/tuple_struct_destructure_fail.rs:27:35
|
LL | Enum::SingleVariant(a, .., b, ..) = Enum::SingleVariant(0, 1);
| -- ^^ can only be used once per tuple struct or variant pattern
| |
| previously used here
error[E0023]: this pattern has 3 fields, but the corresponding tuple struct has 2 fields
--> $DIR/tuple_struct_destructure_fail.rs:30:17
|
LL | struct TupleStruct<S, T>(S, T);
| - - tuple struct has 2 fields
...
LL | TupleStruct(a, a, b) = TupleStruct(1, 2);
| ^ ^ ^ expected 2 fields, found 3
error[E0023]: this pattern has 1 field, but the corresponding tuple struct has 2 fields
--> $DIR/tuple_struct_destructure_fail.rs:32:17
|
LL | struct TupleStruct<S, T>(S, T);
| - - tuple struct has 2 fields
...
LL | TupleStruct(_) = TupleStruct(1, 2);
| ^ expected 2 fields, found 1
|
help: use `_` to explicitly ignore each field
|
LL | TupleStruct(_, _) = TupleStruct(1, 2);
| +++
help: use `..` to ignore all fields
|
LL | TupleStruct(..) = TupleStruct(1, 2);
| ~~
error[E0023]: this pattern has 3 fields, but the corresponding tuple variant has 2 fields
--> $DIR/tuple_struct_destructure_fail.rs:34:25
|
LL | SingleVariant(S, T)
| - - tuple variant has 2 fields
...
LL | Enum::SingleVariant(a, a, b) = Enum::SingleVariant(1, 2);
| ^ ^ ^ expected 2 fields, found 3
error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 2 fields
--> $DIR/tuple_struct_destructure_fail.rs:36:25
|
LL | SingleVariant(S, T)
| - - tuple variant has 2 fields
...
LL | Enum::SingleVariant(_) = Enum::SingleVariant(1, 2);
| ^ expected 2 fields, found 1
|
help: use `_` to explicitly ignore each field
|
LL | Enum::SingleVariant(_, _) = Enum::SingleVariant(1, 2);
| +++
help: use `..` to ignore all fields
|
LL | Enum::SingleVariant(..) = Enum::SingleVariant(1, 2);
| ~~
error[E0070]: invalid left-hand side of assignment
--> $DIR/tuple_struct_destructure_fail.rs:40:12
|
LL | test() = TupleStruct(0, 0);
| ------ ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/tuple_struct_destructure_fail.rs:42:14
|
LL | (test)() = TupleStruct(0, 0);
| -------- ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/tuple_struct_destructure_fail.rs:44:38
|
LL | <Alias::<isize> as Test>::test() = TupleStruct(0, 0);
| -------------------------------- ^
| |
| cannot assign to this expression
error: aborting due to 9 previous errors
Some errors have detailed explanations: E0023, E0070.
For more information about an error, try `rustc --explain E0023`.