diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index 7b17fef492..12c5228f56 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 { fn ast_from_text(text: &str) -> N { let parse = SourceFile::parse(text); - let node = parse.tree().syntax().descendants().find_map(N::cast).unwrap(); + let node = match parse.tree().syntax().descendants().find_map(N::cast) { + Some(it) => it, + None => { + panic!("Failed to make ast node `{}` from text {}", std::any::type_name::(), text) + } + }; let node = node.syntax().clone(); let node = unroot(node); let node = N::cast(node).unwrap();