Honor #![macro_use] in mod source files
This commit is contained in:
parent
286d90de2d
commit
412f180d71
2 changed files with 23 additions and 8 deletions
|
@ -1273,12 +1273,8 @@ impl ModCollector<'_, '_> {
|
|||
// out of line module, resolve, parse and recurse
|
||||
ModKind::Outline {} => {
|
||||
let ast_id = AstId::new(self.file_id, module.ast_id);
|
||||
match self.mod_dir.resolve_declaration(
|
||||
self.def_collector.db,
|
||||
self.file_id,
|
||||
&module.name,
|
||||
path_attr,
|
||||
) {
|
||||
let db = self.def_collector.db;
|
||||
match self.mod_dir.resolve_declaration(db, self.file_id, &module.name, path_attr) {
|
||||
Ok((file_id, is_mod_rs, mod_dir)) => {
|
||||
let module_id = self.push_child_module(
|
||||
module.name.clone(),
|
||||
|
@ -1286,7 +1282,7 @@ impl ModCollector<'_, '_> {
|
|||
Some((file_id, is_mod_rs)),
|
||||
&self.item_tree[module.visibility],
|
||||
);
|
||||
let item_tree = self.def_collector.db.item_tree(file_id.into());
|
||||
let item_tree = db.item_tree(file_id.into());
|
||||
ModCollector {
|
||||
def_collector: &mut *self.def_collector,
|
||||
macro_depth: self.macro_depth,
|
||||
|
@ -1296,7 +1292,12 @@ impl ModCollector<'_, '_> {
|
|||
mod_dir,
|
||||
}
|
||||
.collect(item_tree.top_level_items());
|
||||
if is_macro_use {
|
||||
if is_macro_use
|
||||
|| item_tree
|
||||
.top_level_attrs(db, self.def_collector.def_map.krate)
|
||||
.by_key("macro_use")
|
||||
.exists()
|
||||
{
|
||||
self.import_all_legacy_macros(module_id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -391,11 +391,21 @@ foo!(ok_shadow);
|
|||
mod m4;
|
||||
bar!(OkMacroUse);
|
||||
|
||||
mod m5;
|
||||
baz!(OkMacroUseInner);
|
||||
|
||||
//- /m3/m4.rs
|
||||
foo!(ok_shadow_deep);
|
||||
macro_rules! bar {
|
||||
($x:ident) => { struct $x; }
|
||||
}
|
||||
//- /m3/m5.rs
|
||||
#![macro_use]
|
||||
macro_rules! baz {
|
||||
($x:ident) => { struct $x; }
|
||||
}
|
||||
|
||||
|
||||
"#,
|
||||
expect![[r#"
|
||||
crate
|
||||
|
@ -423,11 +433,15 @@ macro_rules! bar {
|
|||
crate::m3
|
||||
OkAfterInside: t v
|
||||
OkMacroUse: t v
|
||||
OkMacroUseInner: t v
|
||||
m4: t
|
||||
m5: t
|
||||
ok_shadow: v
|
||||
|
||||
crate::m3::m4
|
||||
ok_shadow_deep: v
|
||||
|
||||
crate::m3::m5
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue