mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Expand legacy-scoped macro during collection
This commit is contained in:
parent
787bd3c551
commit
5322cd830e
@ -1467,12 +1467,13 @@ impl ModCollector<'_, '_> {
|
|||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
Ok(Ok(macro_call_id)) => {
|
Ok(Ok(macro_call_id)) => {
|
||||||
self.def_collector.unexpanded_macros.push(MacroDirective {
|
// Legacy macros need to be expanded immediately, so that any macros they produce
|
||||||
module_id: self.module_id,
|
// are in scope.
|
||||||
ast_id,
|
self.def_collector.collect_macro_expansion(
|
||||||
legacy: Some(macro_call_id),
|
self.module_id,
|
||||||
depth: self.macro_depth + 1,
|
macro_call_id,
|
||||||
});
|
self.macro_depth + 1,
|
||||||
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -712,6 +712,27 @@ b! { static = #[] ();}
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn macros_defining_macros() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
macro_rules! item {
|
||||||
|
($item:item) => { $item }
|
||||||
|
}
|
||||||
|
|
||||||
|
item! {
|
||||||
|
macro_rules! indirect_macro { () => { struct S {} } }
|
||||||
|
}
|
||||||
|
|
||||||
|
indirect_macro!();
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
S: t
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn resolves_proc_macros() {
|
fn resolves_proc_macros() {
|
||||||
check(
|
check(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user