diff options
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/ast/make.rs | 7 |
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 | ||
301 | fn ast_from_text<N: AstNode>(text: &str) -> N { | 301 | fn 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(); |