aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_syntax/src/ast/make.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index 7b17fef49..12c5228f5 100644
--- a/crates/ra_syntax/src/ast/make.rs
+++ b/crates/ra_syntax/src/ast/make.rs
@@ -300,7 +300,12 @@ pub fn add_pub_crate_modifier(fn_def: ast::FnDef) -> ast::FnDef {
300 300
301fn ast_from_text<N: AstNode>(text: &str) -> N { 301fn ast_from_text<N: AstNode>(text: &str) -> N {
302 let parse = SourceFile::parse(text); 302 let parse = SourceFile::parse(text);
303 let node = parse.tree().syntax().descendants().find_map(N::cast).unwrap(); 303 let node = match parse.tree().syntax().descendants().find_map(N::cast) {
304 Some(it) => it,
305 None => {
306 panic!("Failed to make ast node `{}` from text {}", std::any::type_name::<N>(), text)
307 }
308 };
304 let node = node.syntax().clone(); 309 let node = node.syntax().clone();
305 let node = unroot(node); 310 let node = unroot(node);
306 let node = N::cast(node).unwrap(); 311 let node = N::cast(node).unwrap();