about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crates/ide_assists/src/handlers/extract_module.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/crates/ide_assists/src/handlers/extract_module.rs b/crates/ide_assists/src/handlers/extract_module.rs
index ccf826b3afe..f43aa61fcb1 100644
--- a/crates/ide_assists/src/handlers/extract_module.rs
+++ b/crates/ide_assists/src/handlers/extract_module.rs
@@ -240,6 +240,11 @@ impl Module {
                             self.expand_and_group_usages_file_wise(ctx, node_def, &mut refs);
                         }
                     },
+                    ast::Macro(it) => {
+                        if let Some(nod) = ctx.sema.to_def(&it) {
+                            self.expand_and_group_usages_file_wise(ctx, Definition::Macro(nod), &mut refs);
+                        }
+                    },
                     _ => (),
                 }
             }
@@ -1376,6 +1381,27 @@ mod modname {
     }
 
     #[test]
+    fn test_extract_module_macro_rules() {
+        check_assist(
+            extract_module,
+            r"
+$0macro_rules! m {
+    () => {};
+}$0
+m! {}
+            ",
+            r"
+mod modname {
+    macro_rules! m {
+        () => {};
+    }
+}
+modname::m! {}
+            ",
+        );
+    }
+
+    #[test]
     fn test_do_not_apply_visibility_modifier_to_trait_impl_items() {
         check_assist(
             extract_module,