mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +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 {
|
||||
let kind = classify_literal(&l.text)
|
||||
.map(|tkn| tkn.kind)
|
||||
.or_else(|| match l.text.as_ref() {
|
||||
"true" => Some(SyntaxKind::TRUE_KW),
|
||||
"false" => Some(SyntaxKind::FALSE_KW),
|
||||
_ => None,
|
||||
})
|
||||
.unwrap();
|
||||
let kind =
|
||||
classify_literal(&l.text).map(|tkn| tkn.kind).unwrap_or_else(|| match l.text.as_ref() {
|
||||
"true" => SyntaxKind::TRUE_KW,
|
||||
"false" => SyntaxKind::FALSE_KW,
|
||||
_ => panic!("Fail to convert given literal {:#?}", &l),
|
||||
});
|
||||
|
||||
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