mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Use panic instead of unwrap
This commit is contained in:
parent
c55a2dbc1d
commit
1908819bf6
1 changed files with 6 additions and 8 deletions
|
@ -438,14 +438,12 @@ fn convert_delim(d: tt::Delimiter, closing: bool) -> TtToken {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convert_literal(l: &tt::Literal) -> TtToken {
|
fn convert_literal(l: &tt::Literal) -> TtToken {
|
||||||
let kind = classify_literal(&l.text)
|
let kind =
|
||||||
.map(|tkn| tkn.kind)
|
classify_literal(&l.text).map(|tkn| tkn.kind).unwrap_or_else(|| match l.text.as_ref() {
|
||||||
.or_else(|| match l.text.as_ref() {
|
"true" => SyntaxKind::TRUE_KW,
|
||||||
"true" => Some(SyntaxKind::TRUE_KW),
|
"false" => SyntaxKind::FALSE_KW,
|
||||||
"false" => Some(SyntaxKind::FALSE_KW),
|
_ => panic!("Fail to convert given literal {:#?}", &l),
|
||||||
_ => None,
|
});
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
TtToken { kind, is_joint_to_next: false, text: l.text.clone(), n_tokens: 1 }
|
TtToken { kind, is_joint_to_next: false, text: l.text.clone(), n_tokens: 1 }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue