diff options
| author | Chayim Refael Friedman <chayimfr@gmail.com> | 2022-02-25 01:23:40 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-25 01:25:42 +0000 |
| commit | 73708d44056b09e037f54eab6a002213a8426558 (patch) | |
| tree | 801580d95bd634ee8f7f2345cc596a9ab8bcc7b6 | |
| parent | 3149e69247a14e3750005deace4ddfd77fc54480 (diff) | |
| download | rust-73708d44056b09e037f54eab6a002213a8426558.tar.gz rust-73708d44056b09e037f54eab6a002213a8426558.zip | |
Update references to macro_rules in the "Extract module" assist
See https://github.com/rust-analyzer/ungrammar/pull/46#issuecomment-1049801890.
| -rw-r--r-- | crates/ide_assists/src/handlers/extract_module.rs | 26 |
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, |
