about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2018-11-12 14:38:44 +1100
committerNicholas Nethercote <nnethercote@mozilla.com>2018-11-12 15:16:03 +1100
commitc6862992d947331cd6556f765f6efbde0a709cf9 (patch)
treea7a97a17e206359789ba630882235c1c4d2764a5 /src/libsyntax
parent5a2ca1a6f18aa93d3120761f614ec2d39b4cb1ac (diff)
downloadrust-c6862992d947331cd6556f765f6efbde0a709cf9.tar.gz
rust-c6862992d947331cd6556f765f6efbde0a709cf9.zip
Change `Lit::short_name` to `Lit::literal_name`.
This avoids a moderately hot allocation in `parse_lit_token`.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/parse/parser.rs2
-rw-r--r--src/libsyntax/parse/token.rs14
2 files changed, 8 insertions, 8 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 68e7e40c43e..d90ec4ea081 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -1956,7 +1956,7 @@ impl<'a> Parser<'a> {
 
                 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()
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 01bc7f6ad30..1c6fc1ac185 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -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"
         }
     }