Skip to content

Commit

Permalink
librustc_lexer: Make "eat_float_exponent" return bool instead of result
Browse files Browse the repository at this point in the history
  • Loading branch information
popzxc committed Nov 3, 2019
1 parent 72767a8 commit e0c45f7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/librustc_lexer/src/lib.rs
Expand Up @@ -480,7 +480,7 @@ impl Cursor<'_> {
match self.first() {
'e' | 'E' => {
self.bump();
empty_exponent = self.float_exponent().is_err()
empty_exponent = !self.eat_float_exponent();
}
_ => (),
}
Expand All @@ -489,7 +489,7 @@ impl Cursor<'_> {
}
'e' | 'E' => {
self.bump();
let empty_exponent = self.float_exponent().is_err();
let empty_exponent = !self.eat_float_exponent();
Float { base, empty_exponent }
}
_ => Int { base, empty_int: false },
Expand Down Expand Up @@ -662,12 +662,14 @@ impl Cursor<'_> {
has_digits
}

fn float_exponent(&mut self) -> Result<(), ()> {
/// Eats the float exponent. Returns true if at least one digit was met,
/// and returns false otherwise.
fn eat_float_exponent(&mut self) -> bool {
debug_assert!(self.prev() == 'e' || self.prev() == 'E');
if self.first() == '-' || self.first() == '+' {
self.bump();
}
if self.eat_decimal_digits() { Ok(()) } else { Err(()) }
self.eat_decimal_digits()
}

// Eats the suffix of the literal, e.g. "_u8".
Expand Down

0 comments on commit e0c45f7

Please sign in to comment.