Skip to content

Commit

Permalink
Turn a few warnings back on when we match token values (#961)
Browse files Browse the repository at this point in the history
Since these are user-supplied, this can help them diagnose bugs
  • Loading branch information
dburgener authored Sep 30, 2024
1 parent 0c41809 commit 2cd9a59
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lalrpop/src/lr1/codegen/parse_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,9 @@ impl<'ascent, 'grammar, W: Write> CodeGenerator<'ascent, 'grammar, W, TableDrive
.emit()?;
rust!(self.out, "{{");

// This match contains user-supplied token names. Reenable some warnings to help them
// catch errors if they've got a bug in their custom lexer implementation
rust!(self.out, "#[warn(unused_variables)]");
rust!(self.out, "match {p}token {{", p = self.prefix);

for (terminal, index) in self.grammar.terminals.all.iter().zip(0..) {
Expand Down
1 change: 1 addition & 0 deletions lalrpop/src/parser/lrgrammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3209,6 +3209,7 @@ ___token: &Tok<'input>,
_: core::marker::PhantomData<(&'input ())>,
) -> Option<usize>
{
#[warn(unused_variables)]
match ___token {
Tok::Enum if true => Some(0),
Tok::Extern if true => Some(1),
Expand Down

0 comments on commit 2cd9a59

Please sign in to comment.