aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src/handlers/replace_unwrap_with_match.rs')
-rw-r--r--crates/ra_assists/src/handlers/replace_unwrap_with_match.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs b/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs
index a46998b8e..c4b56f6e9 100644
--- a/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs
+++ b/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs
@@ -1,7 +1,11 @@
1use std::iter; 1use std::iter;
2 2
3use ra_syntax::{ 3use ra_syntax::{
4 ast::{self, edit::IndentLevel, make}, 4 ast::{
5 self,
6 edit::{AstNodeEdit, IndentLevel},
7 make,
8 },
5 AstNode, 9 AstNode,
6}; 10};
7 11
@@ -51,8 +55,8 @@ pub(crate) fn replace_unwrap_with_match(acc: &mut Assists, ctx: &AssistContext)
51 let err_arm = make::match_arm(iter::once(make::placeholder_pat().into()), unreachable_call); 55 let err_arm = make::match_arm(iter::once(make::placeholder_pat().into()), unreachable_call);
52 56
53 let match_arm_list = make::match_arm_list(vec![ok_arm, err_arm]); 57 let match_arm_list = make::match_arm_list(vec![ok_arm, err_arm]);
54 let match_expr = make::expr_match(caller.clone(), match_arm_list); 58 let match_expr = make::expr_match(caller.clone(), match_arm_list)
55 let match_expr = IndentLevel::from_node(method_call.syntax()).increase_indent(match_expr); 59 .indent(IndentLevel::from_node(method_call.syntax()));
56 60
57 edit.set_cursor(caller.syntax().text_range().start()); 61 edit.set_cursor(caller.syntax().text_range().start());
58 edit.replace_ast::<ast::Expr>(method_call.into(), match_expr); 62 edit.replace_ast::<ast::Expr>(method_call.into(), match_expr);