Skip to content

Commit 1ad17e6

Browse files
merge recommended changes
Co-authored-by: Vadim Petrochenkov <[email protected]>
1 parent db78fcf commit 1ad17e6

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

compiler/rustc_lexer/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ impl Cursor<'_> {
688688
}
689689
}
690690
('e' | 'E', '0'..='9' | '+' | '-') => {
691-
// definitely an exponent
691+
// Definitely an exponent (which still can be empty).
692692
self.bump();
693693
empty_exponent = !self.eat_float_exponent();
694694
suffix_start = self.pos_within_token();
@@ -700,7 +700,7 @@ impl Cursor<'_> {
700700
(Float { base, empty_exponent }, suffix_start)
701701
}
702702
('e' | 'E', '_') => {
703-
// see above bock for similar apporach
703+
// See above block for similar approach.
704704
let non_exponent_suffix_start = self.pos_within_token();
705705
self.bump();
706706
while matches!(self.first(), '_') {
@@ -718,7 +718,7 @@ impl Cursor<'_> {
718718
}
719719
}
720720
('e' | 'E', '0'..='9' | '+' | '-') => {
721-
// definitely an exponent
721+
// // Definitely an exponent (which still can be empty).
722722
self.bump();
723723
let empty_exponent = !self.eat_float_exponent();
724724
let suffix_start = self.pos_within_token();
@@ -978,7 +978,7 @@ impl Cursor<'_> {
978978
}
979979
}
980980

981-
/// Returns `true` if a digit was consumed (rather than just '_')
981+
/// Returns `true` if a digit was consumed (rather than just '_'s).
982982
fn eat_decimal_digits(&mut self) -> bool {
983983
let mut has_digits = false;
984984
loop {

compiler/rustc_session/src/errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ pub fn report_lit_error(
377377
s.len() > 1 && s.starts_with(first_chars) && s[1..].chars().all(|c| c.is_ascii_digit())
378378
}
379379

380-
fn looks_like_exponent(s: &str) -> bool {
380+
fn looks_like_empty_exponent(s: &str) -> bool {
381381
s.len() == 1 && matches!(s.chars().next(), Some('e' | 'E'))
382382
}
383383

@@ -413,7 +413,7 @@ pub fn report_lit_error(
413413
if looks_like_width_suffix(&['i', 'u'], suf) {
414414
// If it looks like a width, try to be helpful.
415415
dcx.emit_err(InvalidIntLiteralWidth { span, width: suf[1..].into() })
416-
} else if looks_like_exponent(suf) {
416+
} else if looks_like_empty_exponent(suf) {
417417
dcx.emit_err(EmptyFloatExponent { span })
418418
} else if let Some(fixed) = fix_base_capitalisation(lit.symbol.as_str(), suf) {
419419
dcx.emit_err(InvalidNumLiteralBasePrefix { span, fixed })
@@ -426,7 +426,7 @@ pub fn report_lit_error(
426426
if looks_like_width_suffix(&['f'], suf) {
427427
// If it looks like a width, try to be helpful.
428428
dcx.emit_err(InvalidFloatLiteralWidth { span, width: suf[1..].to_string() })
429-
} else if looks_like_exponent(suf) {
429+
} else if looks_like_empty_exponent(suf) {
430430
dcx.emit_err(EmptyFloatExponent { span })
431431
} else {
432432
dcx.emit_err(InvalidFloatLiteralSuffix { span, suffix: suf.to_string() })

0 commit comments

Comments
 (0)