]> git.lizzy.rs Git - rust.git/commitdiff
feat: add "mentoring instructions" test for pull up assist
authorAleksey Kladov <aleksey.kladov@gmail.com>
Sat, 8 May 2021 20:19:08 +0000 (23:19 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Sat, 8 May 2021 20:19:08 +0000 (23:19 +0300)
crates/ide_assists/src/handlers/pull_assignment_up.rs

index 602c3813ede483343060e85c37f432581fbe7706..28d14b9c3f14e9c4091a0efeaa25c37daaa97de1 100644 (file)
@@ -95,7 +95,6 @@ fn collect_match(&mut self, match_expr: &ast::MatchExpr) -> Option<()> {
         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(