You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
enumSide{Left,Right}fnmatch_side(s:Side){match s {Side::Left => ()Side::Right => ()}}
Currently shows:
error: expected one of `,`, `.`, `?`, `}`, or an operator, found `Side`
--> src/lib.rs:6:9
|
5 | Side::Left => ()
| -- - expected one of `,`, `.`, `?`, `}`, or an operator
| |
| while parsing the `match` arm starting here
6 | Side::Right => ()
| ^^^^ unexpected token
It should be expanded with a help message to:
5 | Side::Left => ()
| ^ help: add , here
It should probably only emit this diagnostic if, by rechecking the match with the , there, it can find a pattern followed by =>.
For a more advanced case, consider this more convoluted example:
error: expected expression, found reserved identifier `_`
--> src/lib.rs:6:22
|
6 | (Side::Right(_),) => ()
| ^ expected expression
error: expected one of `,`, `.`, `?`, `}`, or an operator, found `=>`
--> src/lib.rs:6:27
|
5 | (Side::Left(_),) => ()
| -- while parsing the `match` arm starting here
6 | (Side::Right(_),) => ()
| ^^ expected one of `,`, `.`, `?`, `}`, or an operator
In this case, the pattern sort of looks like a function call and not an immediate incorrect token for an expression. The vast majority of cases can probably be caught by checking at the newline if what's after is a pattern. But there might also be a simple solution based on the pattern and expression grammars. Of course, it almost always triggers the found =>, so that could be used as a starting point.
The text was updated successfully, but these errors were encountered:
…-arm, r=estebank
Recover missing comma after match arm
If we're missing a comma after a match arm expression, try parsing another pattern and a following `=>`. If we find both of those, then recover by suggesting to insert a `,`.
Fixesrust-lang#80112
Currently shows:
It should be expanded with a help message to:
It should probably only emit this diagnostic if, by rechecking the match with the
,
there, it can find a pattern followed by=>
.For a more advanced case, consider this more convoluted example:
It currently emits:
In this case, the pattern sort of looks like a function call and not an immediate incorrect token for an expression. The vast majority of cases can probably be caught by checking at the newline if what's after is a pattern. But there might also be a simple solution based on the pattern and expression grammars. Of course, it almost always triggers the
found =>
, so that could be used as a starting point.The text was updated successfully, but these errors were encountered: