Skip to content

Commit 64ea02a

Browse files
committed
Rollup merge of #55905 - nnethercote:short_name-to-literal_name, r=Mark-Simulacrum
Change `Lit::short_name` to `Lit::literal_name`. This avoids a moderately hot allocation in `parse_lit_token`. r? @Mark-Simulacrum
2 parents 4d76440 + c686299 commit 64ea02a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/libsyntax/parse/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1956,7 +1956,7 @@ impl<'a> Parser<'a> {
19561956

19571957
if suffix_illegal {
19581958
let sp = self.span;
1959-
self.expect_no_suffix(sp, &format!("{} literal", lit.short_name()), suf)
1959+
self.expect_no_suffix(sp, lit.literal_name(), suf)
19601960
}
19611961

19621962
result.unwrap()

src/libsyntax/parse/token.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ pub enum Lit {
7979
}
8080

8181
impl Lit {
82-
crate fn short_name(&self) -> &'static str {
82+
crate fn literal_name(&self) -> &'static str {
8383
match *self {
84-
Byte(_) => "byte",
85-
Char(_) => "char",
86-
Integer(_) => "integer",
87-
Float(_) => "float",
88-
Str_(_) | StrRaw(..) => "string",
89-
ByteStr(_) | ByteStrRaw(..) => "byte string"
84+
Byte(_) => "byte literal",
85+
Char(_) => "char literal",
86+
Integer(_) => "integer literal",
87+
Float(_) => "float literal",
88+
Str_(_) | StrRaw(..) => "string literal",
89+
ByteStr(_) | ByteStrRaw(..) => "byte string literal"
9090
}
9191
}
9292

0 commit comments

Comments
 (0)