Skip to content

Commit e0c45f7

Browse files
committed
librustc_lexer: Make "eat_float_exponent" return bool instead of result
1 parent 72767a8 commit e0c45f7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/librustc_lexer/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ impl Cursor<'_> {
480480
match self.first() {
481481
'e' | 'E' => {
482482
self.bump();
483-
empty_exponent = self.float_exponent().is_err()
483+
empty_exponent = !self.eat_float_exponent();
484484
}
485485
_ => (),
486486
}
@@ -489,7 +489,7 @@ impl Cursor<'_> {
489489
}
490490
'e' | 'E' => {
491491
self.bump();
492-
let empty_exponent = self.float_exponent().is_err();
492+
let empty_exponent = !self.eat_float_exponent();
493493
Float { base, empty_exponent }
494494
}
495495
_ => Int { base, empty_int: false },
@@ -662,12 +662,14 @@ impl Cursor<'_> {
662662
has_digits
663663
}
664664

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

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

0 commit comments

Comments
 (0)