提交 f3c2dca3 编写于 作者: J Jeffrey Seyfried

Remove scope placeholders from the crate root.

上级 c86c8d41
......@@ -191,8 +191,15 @@ pub fn new(cx: &'a mut ExtCtxt<'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 @@ fn fold_item(&mut self, item: P<ast::Item>) -> SmallVector<P<ast::Item>> {
})
}
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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册