We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 74e72e9 + 0f1d391 commit bfb40a6Copy full SHA for bfb40a6
crates/ra_syntax/src/ast/make.rs
@@ -300,7 +300,12 @@ pub fn add_pub_crate_modifier(fn_def: ast::FnDef) -> ast::FnDef {
300
301
fn ast_from_text<N: AstNode>(text: &str) -> N {
302
let parse = SourceFile::parse(text);
303
- let node = parse.tree().syntax().descendants().find_map(N::cast).unwrap();
+ 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
+ };
309
let node = node.syntax().clone();
310
let node = unroot(node);
311
let node = N::cast(node).unwrap();
0 commit comments