diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-09 13:40:45 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-09 13:40:45 +0100 |
commit | 5af66e54866b2b9942b2a5298a8874ce6a44a1d5 (patch) | |
tree | 9097335ae61afaf895c61ec1532fbf52aeb13aa5 /crates/ra_assists/src/handlers/replace_unwrap_with_match.rs | |
parent | 25e37e2c93ba91a8956fdff8bbe9701c623d386f (diff) | |
parent | 231fddab5420ffe5edf7b93609ea21155653254a (diff) |
Merge #4387
4387: More fluent indent API r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
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.rs | 10 |
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 @@ | |||
1 | use std::iter; | 1 | use std::iter; |
2 | 2 | ||
3 | use ra_syntax::{ | 3 | use 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); |