From 1908819bf6432016527f4bd3b0f22500b85cab5f Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Fri, 26 Apr 2019 02:56:44 +0800 Subject: Use panic instead of unwrap --- crates/ra_mbe/src/subtree_source.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'crates') 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 { } 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 } } -- cgit v1.2.3