Skip to content

Commit 5c33ca4

Browse files
authored
Merge pull request #22437 from Albab-Hasan/extract-module-macro-import
fix: `extract_module` missing import for macro calls
2 parents 9acc026 + 8bd24d2 commit 5c33ca4

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

crates/ide-assists/src/handlers/extract_module.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@ fn check_def_in_mod_and_out_sel(
733733
Definition::Static(x) => check_item!(x),
734734
Definition::Trait(x) => check_item!(x),
735735
Definition::TypeAlias(x) => check_item!(x),
736+
Definition::Macro(x) => check_item!(x),
736737
_ => {}
737738
}
738739

@@ -1813,4 +1814,33 @@ mod foo {
18131814
"#,
18141815
)
18151816
}
1817+
1818+
#[test]
1819+
fn test_extract_module_macro_call_import() {
1820+
check_assist(
1821+
extract_module,
1822+
r"
1823+
macro_rules! my_macro {
1824+
() => {};
1825+
}
1826+
1827+
$0fn bar() {
1828+
my_macro!();
1829+
}$0
1830+
",
1831+
r"
1832+
macro_rules! my_macro {
1833+
() => {};
1834+
}
1835+
1836+
mod modname {
1837+
use super::my_macro;
1838+
1839+
pub(crate) fn bar() {
1840+
my_macro!();
1841+
}
1842+
}
1843+
",
1844+
)
1845+
}
18161846
}

0 commit comments

Comments
 (0)