Remove scope placeholders from the crate root.
This commit is contained in:
parent
c86c8d41a2
commit
f3c2dca353
1 changed files with 13 additions and 2 deletions
|
|
@ -191,8 +191,15 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
|||
fn expand_crate(&mut self, mut krate: ast::Crate) -> ast::Crate {
|
||||
let err_count = self.cx.parse_sess.span_diagnostic.err_count();
|
||||
|
||||
let items = Expansion::Items(SmallVector::many(krate.module.items));
|
||||
krate.module.items = self.expand(items).make_items().into();
|
||||
let mut krate_item = placeholder(ExpansionKind::Items, ast::DUMMY_NODE_ID)
|
||||
.make_items().pop().unwrap().unwrap();
|
||||
krate_item.node = ast::ItemKind::Mod(krate.module);
|
||||
let krate_item = Expansion::Items(SmallVector::one(P(krate_item)));
|
||||
|
||||
krate.module = match self.expand(krate_item).make_items().pop().unwrap().unwrap().node {
|
||||
ast::ItemKind::Mod(module) => module,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
krate.exported_macros = mem::replace(&mut self.cx.exported_macros, Vec::new());
|
||||
|
||||
for def in &mut krate.exported_macros {
|
||||
|
|
@ -596,6 +603,10 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
|
|||
})
|
||||
}
|
||||
ast::ItemKind::Mod(ast::Mod { inner, .. }) => {
|
||||
if item.ident == keywords::Invalid.ident() {
|
||||
return noop_fold_item(item, self);
|
||||
}
|
||||
|
||||
let mut module = (*self.cx.current_expansion.module).clone();
|
||||
module.mod_path.push(item.ident);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue