mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Convert bool to ident instead of literal in mbe
This commit is contained in:
parent
b949500126
commit
a1b5cf81eb
5 changed files with 47 additions and 14 deletions
|
@ -158,20 +158,17 @@ fn convert_literal(l: &tt::Literal) -> TtToken {
|
|||
let kind = lex_single_syntax_kind(&l.text)
|
||||
.map(|(kind, _error)| kind)
|
||||
.filter(|kind| kind.is_literal())
|
||||
.unwrap_or_else(|| match l.text.as_ref() {
|
||||
"true" => T![true],
|
||||
"false" => T![false],
|
||||
_ => panic!("Fail to convert given literal {:#?}", &l),
|
||||
});
|
||||
.unwrap_or_else(|| panic!("Fail to convert given literal {:#?}", &l));
|
||||
|
||||
TtToken { kind, is_joint_to_next: false, text: l.text.clone() }
|
||||
}
|
||||
|
||||
fn convert_ident(ident: &tt::Ident) -> TtToken {
|
||||
let kind = if ident.text.starts_with('\'') {
|
||||
LIFETIME
|
||||
} else {
|
||||
SyntaxKind::from_keyword(ident.text.as_str()).unwrap_or(IDENT)
|
||||
let kind = match ident.text.as_ref() {
|
||||
"true" => T![true],
|
||||
"false" => T![false],
|
||||
i if i.starts_with('\'') => LIFETIME,
|
||||
_ => SyntaxKind::from_keyword(ident.text.as_str()).unwrap_or(IDENT),
|
||||
};
|
||||
|
||||
TtToken { kind, is_joint_to_next: false, text: ident.text.clone() }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue