about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crates/ide-assists/src/handlers/generate_function.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/crates/ide-assists/src/handlers/generate_function.rs b/crates/ide-assists/src/handlers/generate_function.rs
index 5b13e01b133..f74fc5df4bd 100644
--- a/crates/ide-assists/src/handlers/generate_function.rs
+++ b/crates/ide-assists/src/handlers/generate_function.rs
@@ -404,7 +404,11 @@ impl FunctionBuilder {
             leading_ws,
             ret_type: fn_def.ret_type(),
             // PANIC: we guarantee we always create a function body with a tail expr
-            tail_expr: fn_def.body().unwrap().tail_expr().unwrap(),
+            tail_expr: fn_def
+                .body()
+                .expect("generated function should have a body")
+                .tail_expr()
+                .expect("function body should have a tail expression"),
             should_focus_return_type: self.should_focus_return_type,
             fn_def,
             trailing_ws,
@@ -683,7 +687,7 @@ where
 {
     // This function should be only called with `Impl`, `Trait`, or `Function`, for which it's
     // infallible to get source ast.
-    let node = ctx.sema.source(def).unwrap().value;
+    let node = ctx.sema.source(def).expect("definition's source couldn't be found").value;
     let generic_params = node.generic_param_list().into_iter().flat_map(|it| it.generic_params());
     let where_clauses = node.where_clause().into_iter().flat_map(|it| it.predicates());
     (generic_params, where_clauses)