mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-16 01:38:13 +00:00
Merge #8128
8128: Expand legacy-scoped macro during collection r=jonas-schievink a=jonas-schievink Fixes https://github.com/rust-analyzer/rust-analyzer/issues/8120 Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
commit
5bb65bb496
2 changed files with 28 additions and 6 deletions
|
@ -1467,12 +1467,13 @@ impl ModCollector<'_, '_> {
|
|||
},
|
||||
) {
|
||||
Ok(Ok(macro_call_id)) => {
|
||||
self.def_collector.unexpanded_macros.push(MacroDirective {
|
||||
module_id: self.module_id,
|
||||
ast_id,
|
||||
legacy: Some(macro_call_id),
|
||||
depth: self.macro_depth + 1,
|
||||
});
|
||||
// Legacy macros need to be expanded immediately, so that any macros they produce
|
||||
// are in scope.
|
||||
self.def_collector.collect_macro_expansion(
|
||||
self.module_id,
|
||||
macro_call_id,
|
||||
self.macro_depth + 1,
|
||||
);
|
||||
|
||||
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]
|
||||
fn resolves_proc_macros() {
|
||||
check(
|
||||
|
|
Loading…
Reference in a new issue