aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2019-04-25 19:56:44 +0100
committerEdwin Cheng <[email protected]>2019-04-25 19:56:44 +0100
commit1908819bf6432016527f4bd3b0f22500b85cab5f (patch)
treef48081403383b7a00a3c297b2ff24a7c11ddd07e /crates/ra_mbe
parentc55a2dbc1de8ba42df57b70f652eb6a0c0bbc9f6 (diff)
Use panic instead of unwrap
Diffstat (limited to 'crates/ra_mbe')
-rw-r--r--crates/ra_mbe/src/subtree_source.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/crates/ra_mbe/src/subtree_source.rs b/crates/ra_mbe/src/subtree_source.rs
index 845020f4e..6255ea304 100644
--- a/crates/ra_mbe/src/subtree_source.rs
+++ b/crates/ra_mbe/src/subtree_source.rs
@@ -438,14 +438,12 @@ fn convert_delim(d: tt::Delimiter, closing: bool) -> TtToken {
438} 438}
439 439
440fn convert_literal(l: &tt::Literal) -> TtToken { 440fn convert_literal(l: &tt::Literal) -> TtToken {
441 let kind = classify_literal(&l.text) 441 let kind =
442 .map(|tkn| tkn.kind) 442 classify_literal(&l.text).map(|tkn| tkn.kind).unwrap_or_else(|| match l.text.as_ref() {
443 .or_else(|| match l.text.as_ref() { 443 "true" => SyntaxKind::TRUE_KW,
444 "true" => Some(SyntaxKind::TRUE_KW), 444 "false" => SyntaxKind::FALSE_KW,
445 "false" => Some(SyntaxKind::FALSE_KW), 445 _ => panic!("Fail to convert given literal {:#?}", &l),
446 _ => None, 446 });
447 })
448 .unwrap();
449 447
450 TtToken { kind, is_joint_to_next: false, text: l.text.clone(), n_tokens: 1 } 448 TtToken { kind, is_joint_to_next: false, text: l.text.clone(), n_tokens: 1 }
451} 449}