Skip to content

Commit 0bb3dad

Browse files
committed
extract error_float_lits-must_have_int_part
1 parent aa8adba commit 0bb3dad

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/librustc_parse/parser/expr.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,14 +1141,7 @@ impl<'a> Parser<'a> {
11411141
});
11421142
if let Some(token) = &recovered {
11431143
self.bump();
1144-
self.struct_span_err(token.span, "float literals must have an integer part")
1145-
.span_suggestion(
1146-
token.span,
1147-
"must have an integer part",
1148-
pprust::token_to_string(token),
1149-
Applicability::MachineApplicable,
1150-
)
1151-
.emit();
1144+
self.error_float_lits_must_have_int_part(&token);
11521145
}
11531146
}
11541147

@@ -1177,6 +1170,17 @@ impl<'a> Parser<'a> {
11771170
}
11781171
}
11791172

1173+
fn error_float_lits_must_have_int_part(&self, token: &Token) {
1174+
self.struct_span_err(token.span, "float literals must have an integer part")
1175+
.span_suggestion(
1176+
token.span,
1177+
"must have an integer part",
1178+
pprust::token_to_string(token),
1179+
Applicability::MachineApplicable,
1180+
)
1181+
.emit();
1182+
}
1183+
11801184
fn report_lit_error(&self, err: LitError, lit: token::Lit, span: Span) {
11811185
// Checks if `s` looks like i32 or u1234 etc.
11821186
fn looks_like_width_suffix(first_chars: &[char], s: &str) -> bool {

0 commit comments

Comments
 (0)