diff options
| author | Igor Aleksanov <popzxc@yandex.ru> | 2019-11-03 11:43:47 +0300 |
|---|---|---|
| committer | Igor Aleksanov <popzxc@yandex.ru> | 2019-11-03 11:43:47 +0300 |
| commit | e0c45f7ee7b1c3882d08e9b71e753e3251c2dff1 (patch) | |
| tree | bdbb424f5a6a30129b03fce8558fc74b22734482 | |
| parent | 72767a805679b40c1884f1051b67cc43b46fc4e8 (diff) | |
| download | rust-e0c45f7ee7b1c3882d08e9b71e753e3251c2dff1.tar.gz rust-e0c45f7ee7b1c3882d08e9b71e753e3251c2dff1.zip | |
librustc_lexer: Make "eat_float_exponent" return bool instead of result
| -rw-r--r-- | src/librustc_lexer/src/lib.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/librustc_lexer/src/lib.rs b/src/librustc_lexer/src/lib.rs index 576b4ff5ed6..92d99f37713 100644 --- a/src/librustc_lexer/src/lib.rs +++ b/src/librustc_lexer/src/lib.rs @@ -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(); } _ => (), } @@ -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 }, @@ -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". |
