未验证 提交 64ea02a9 编写于 作者: K kennytm

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
......@@ -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()
......
......@@ -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"
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册