aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
authorUnreal Hoang <[email protected]>2020-03-26 09:16:10 +0000
committerUnreal Hoang <[email protected]>2020-03-26 15:08:12 +0000
commitd9df0f43ac669a68dc76466a2f2c21885b5af2dd (patch)
treec20d4c2a698b33c83014664754379b182b659dc9 /crates/ra_syntax/src/ast
parent785eb32f49653fbc5789396af4fa6ad61f89fb38 (diff)
Assist: replace unwrap with match
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/make.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index 1145b69e8..e29600439 100644
--- a/crates/ra_syntax/src/ast/make.rs
+++ b/crates/ra_syntax/src/ast/make.rs
@@ -250,6 +250,10 @@ pub fn token(kind: SyntaxKind) -> SyntaxToken {
250 .unwrap_or_else(|| panic!("unhandled token: {:?}", kind)) 250 .unwrap_or_else(|| panic!("unhandled token: {:?}", kind))
251} 251}
252 252
253pub fn unreachable_macro_call() -> ast::MacroCall {
254 ast_from_text(&format!("unreachable!()"))
255}
256
253fn ast_from_text<N: AstNode>(text: &str) -> N { 257fn ast_from_text<N: AstNode>(text: &str) -> N {
254 let parse = SourceFile::parse(text); 258 let parse = SourceFile::parse(text);
255 let node = parse.tree().syntax().descendants().find_map(N::cast).unwrap(); 259 let node = parse.tree().syntax().descendants().find_map(N::cast).unwrap();