From 1ee12b5db17f6f4396af6bfd6ba2528de7f86c78 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 8 May 2021 23:19:08 +0300 Subject: feat: add "mentoring instructions" test for pull up assist --- .../ide_assists/src/handlers/pull_assignment_up.rs | 33 +++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'crates/ide_assists/src') diff --git a/crates/ide_assists/src/handlers/pull_assignment_up.rs b/crates/ide_assists/src/handlers/pull_assignment_up.rs index 602c3813e..28d14b9c3 100644 --- a/crates/ide_assists/src/handlers/pull_assignment_up.rs +++ b/crates/ide_assists/src/handlers/pull_assignment_up.rs @@ -95,7 +95,6 @@ impl<'a> AssignmentsCollector<'a> { for arm in match_expr.match_arm_list()?.arms() { match arm.expr()? { ast::Expr::BlockExpr(block) => self.collect_block(&block)?, - // TODO: Handle this while we are at it? _ => return None, } } @@ -241,6 +240,38 @@ fn foo() { ); } + #[test] + #[ignore] + fn test_pull_assignment_up_assignment_expressions() { + check_assist( + pull_assignment_up, + r#" +fn foo() { + let mut a = 1; + + match 1 { + 1 => { $0a = 2; }, + 2 => a = 3, + 3 => { + a = 4 + } + } +}"#, + r#" +fn foo() { + let mut a = 1; + + a = match 1 { + 1 => { 2 }, + 2 => 3, + 3 => { + 4 + } + }; +}"#, + ); + } + #[test] fn test_pull_assignment_up_not_last_not_applicable() { check_assist_not_applicable( -- cgit v1.2.3