aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-05-08 21:19:08 +0100
committerAleksey Kladov <[email protected]>2021-05-08 21:19:08 +0100
commit1ee12b5db17f6f4396af6bfd6ba2528de7f86c78 (patch)
treeb6fc312163e09bd3eef55b9adaf48cb1ccffbe26 /crates/ide_assists
parent1755b57e1a568176bc0bda144889460e7d603cd5 (diff)
feat: add "mentoring instructions" test for pull up assist
Diffstat (limited to 'crates/ide_assists')
-rw-r--r--crates/ide_assists/src/handlers/pull_assignment_up.rs33
1 files changed, 32 insertions, 1 deletions
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> {
95 for arm in match_expr.match_arm_list()?.arms() { 95 for arm in match_expr.match_arm_list()?.arms() {
96 match arm.expr()? { 96 match arm.expr()? {
97 ast::Expr::BlockExpr(block) => self.collect_block(&block)?, 97 ast::Expr::BlockExpr(block) => self.collect_block(&block)?,
98 // TODO: Handle this while we are at it?
99 _ => return None, 98 _ => return None,
100 } 99 }
101 } 100 }
@@ -242,6 +241,38 @@ fn foo() {
242 } 241 }
243 242
244 #[test] 243 #[test]
244 #[ignore]
245 fn test_pull_assignment_up_assignment_expressions() {
246 check_assist(
247 pull_assignment_up,
248 r#"
249fn foo() {
250 let mut a = 1;
251
252 match 1 {
253 1 => { $0a = 2; },
254 2 => a = 3,
255 3 => {
256 a = 4
257 }
258 }
259}"#,
260 r#"
261fn foo() {
262 let mut a = 1;
263
264 a = match 1 {
265 1 => { 2 },
266 2 => 3,
267 3 => {
268 4
269 }
270 };
271}"#,
272 );
273 }
274
275 #[test]
245 fn test_pull_assignment_up_not_last_not_applicable() { 276 fn test_pull_assignment_up_not_last_not_applicable() {
246 check_assist_not_applicable( 277 check_assist_not_applicable(
247 pull_assignment_up, 278 pull_assignment_up,