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
I get a compile error in generated code, with a terrible "help":
error[E0004]: non-exhaustive patterns: `&Var` not covered
--> src/main.rs:21:10
|
21 | enum Token {
| ^^^^^ pattern `&Var` not covered
|
note: `Token` defined here
--> src/main.rs:8:5
|
5 | pub enum Token {
| -----
...
8 | Var,
| ^^^ not covered
= note: the matched value is of type `&Token`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
23 ~ ")" => Token,::LParen,
24 ~ &Var => todo!()::RParen,
|
The problem is in the token_value function that we generate to extract values (fields) of tokens and convert them to SemanticActionRersult type: (which should probably be called "value", as it defines the values for the value stack)
Here unused tokens are not matched, causing the non-exhaustive pattern match error.
I think we should be able to just add a _ => unreachable!() at the end here. We should also probably add #[inline(always)] as in the call sites this function will be called after the next token matches a pattern with the token, so the constructor is always known, and the compiler should be able to easily eliminate this match expression using the known shape (constructor) of the token.
The text was updated successfully, but these errors were encountered:
If I have this token type:
and don't use the
Var
token in my parser:I get a compile error in generated code, with a terrible "help":
The problem is in the
token_value
function that we generate to extract values (fields) of tokens and convert them toSemanticActionRersult
type: (which should probably be called "value", as it defines the values for the value stack)Here unused tokens are not matched, causing the non-exhaustive pattern match error.
I think we should be able to just add a
_ => unreachable!()
at the end here. We should also probably add#[inline(always)]
as in the call sites this function will be called after the next token matches a pattern with the token, so the constructor is always known, and the compiler should be able to easily eliminate thismatch
expression using the known shape (constructor) of the token.The text was updated successfully, but these errors were encountered: