Skip to content

Commit

Permalink
Don't try to eat non-existent decimal digits.
Browse files Browse the repository at this point in the history
After seeing a `0`, if it's followed by any of `[0-9]`, `_`, `.`, `e`,
or `E`, we consume all the digits. But in the `.`, `e` and `E` cases
this is pointless because we know there aren't any digits.
  • Loading branch information
nnethercote committed May 15, 2023
1 parent 19967c5 commit e52794d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions compiler/rustc_lexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,10 +604,14 @@ impl Cursor<'_> {
return Int { base, empty_int: true };
}
}
// Not a base prefix.
'0'..='9' | '_' | '.' | 'e' | 'E' => {
// Not a base prefix; consume additional digits.
'0'..='9' | '_' => {
self.eat_decimal_digits();
}

// Also not a base prefix; nothing more to do here.
'.' | 'e' | 'E' => {}

// Just a 0.
_ => return Int { base, empty_int: false },
}
Expand Down

0 comments on commit e52794d

Please sign in to comment.