about summary refs log tree commit diff
path: root/src/librustc_parse/parser
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-12-06 23:51:18 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2019-12-23 13:43:35 +0100
commit0bb3dad5a63826f8497ca69fd846ca53b5f08a69 (patch)
tree58dc1fde43b2f903446c20260e70e7b44a41da07 /src/librustc_parse/parser
parentaa8adba8fbd408d94af21fbf768ffab95f7866ef (diff)
downloadrust-0bb3dad5a63826f8497ca69fd846ca53b5f08a69.tar.gz
rust-0bb3dad5a63826f8497ca69fd846ca53b5f08a69.zip
extract error_float_lits-must_have_int_part
Diffstat (limited to 'src/librustc_parse/parser')
-rw-r--r--src/librustc_parse/parser/expr.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs
index 982a7e8db54..72a9311ee27 100644
--- a/src/librustc_parse/parser/expr.rs
+++ b/src/librustc_parse/parser/expr.rs
@@ -1141,14 +1141,7 @@ impl<'a> Parser<'a> {
             });
             if let Some(token) = &recovered {
                 self.bump();
-                self.struct_span_err(token.span, "float literals must have an integer part")
-                    .span_suggestion(
-                        token.span,
-                        "must have an integer part",
-                        pprust::token_to_string(token),
-                        Applicability::MachineApplicable,
-                    )
-                    .emit();
+                self.error_float_lits_must_have_int_part(&token);
             }
         }
 
@@ -1177,6 +1170,17 @@ impl<'a> Parser<'a> {
         }
     }
 
+    fn error_float_lits_must_have_int_part(&self, token: &Token) {
+        self.struct_span_err(token.span, "float literals must have an integer part")
+            .span_suggestion(
+                token.span,
+                "must have an integer part",
+                pprust::token_to_string(token),
+                Applicability::MachineApplicable,
+            )
+            .emit();
+    }
+
     fn report_lit_error(&self, err: LitError, lit: token::Lit, span: Span) {
         // Checks if `s` looks like i32 or u1234 etc.
         fn looks_like_width_suffix(first_chars: &[char], s: &str) -> bool {