]> git.lizzy.rs Git - rust.git/commitdiff
Change `Lit::short_name` to `Lit::literal_name`.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 12 Nov 2018 03:38:44 +0000 (14:38 +1100)
committerNicholas Nethercote <nnethercote@mozilla.com>
Mon, 12 Nov 2018 04:16:03 +0000 (15:16 +1100)
This avoids a moderately hot allocation in `parse_lit_token`.

src/libsyntax/parse/parser.rs
src/libsyntax/parse/token.rs

index 68e7e40c43efe4a1b74c035905c376c629e5662f..d90ec4ea081b233d80e54888834971a40529dd49 100644 (file)
@@ -1956,7 +1956,7 @@ fn parse_lit_token(&mut self) -> PResult<'a, LitKind> {
 
                 if suffix_illegal {
                     let sp = self.span;
-                    self.expect_no_suffix(sp, &format!("{} literal", lit.short_name()), suf)
+                    self.expect_no_suffix(sp, lit.literal_name(), suf)
                 }
 
                 result.unwrap()
index 01bc7f6ad302be195c1ef2369a219f3573fab4ea..1c6fc1ac1853f1c3007baae3493d7e7343de22d1 100644 (file)
@@ -79,14 +79,14 @@ pub enum Lit {
 }
 
 impl Lit {
-    crate fn short_name(&self) -> &'static str {
+    crate fn literal_name(&self) -> &'static str {
         match *self {
-            Byte(_) => "byte",
-            Char(_) => "char",
-            Integer(_) => "integer",
-            Float(_) => "float",
-            Str_(_) | StrRaw(..) => "string",
-            ByteStr(_) | ByteStrRaw(..) => "byte string"
+            Byte(_) => "byte literal",
+            Char(_) => "char literal",
+            Integer(_) => "integer literal",
+            Float(_) => "float literal",
+            Str_(_) | StrRaw(..) => "string literal",
+            ByteStr(_) | ByteStrRaw(..) => "byte string literal"
         }
     }