Add comment and clean up expand_annotatable

This commit is contained in:
Jeffrey Seyfried 2016-06-09 00:47:52 +00:00
parent 13e3925e8d
commit dbf0326ddc
2 changed files with 8 additions and 8 deletions

View File

@ -942,6 +942,8 @@ impl SyntaxEnv {
}
pub fn is_crate_root(&mut self) -> bool {
// The first frame is pushed in `SyntaxEnv::new()` and the second frame is
// pushed when folding the crate root pseudo-module (c.f. noop_fold_crate).
self.chain.len() == 2
}
}

View File

@ -726,13 +726,11 @@ fn expand_annotatable(a: Annotatable,
let new_items: SmallVector<Annotatable> = match a {
Annotatable::Item(it) => match it.node {
ast::ItemKind::Mac(..) => {
let new_items: SmallVector<P<ast::Item>> = it.and_then(|it| match it.node {
it.and_then(|it| match it.node {
ItemKind::Mac(mac) =>
expand_mac_invoc(mac, Some(it.ident), it.attrs, it.span, fld),
_ => unreachable!(),
});
new_items.into_iter().map(|i| Annotatable::Item(i)).collect()
})
}
ast::ItemKind::Mod(_) | ast::ItemKind::ForeignMod(_) => {
let valid_ident =
@ -748,7 +746,7 @@ fn expand_annotatable(a: Annotatable,
if valid_ident {
fld.cx.mod_pop();
}
result.into_iter().map(|i| Annotatable::Item(i)).collect()
result
},
ast::ItemKind::ExternCrate(_) => {
// We need to error on `#[macro_use] extern crate` when it isn't at the
@ -757,10 +755,10 @@ fn expand_annotatable(a: Annotatable,
for def in fld.cx.loader.load_crate(&it, allows_macros) {
fld.cx.insert_macro(def);
}
SmallVector::one(Annotatable::Item(it))
},
_ => noop_fold_item(it, fld).into_iter().map(|i| Annotatable::Item(i)).collect(),
SmallVector::one(it)
},
_ => noop_fold_item(it, fld),
}.into_iter().map(|i| Annotatable::Item(i)).collect(),
Annotatable::TraitItem(it) => match it.node {
ast::TraitItemKind::Method(_, Some(_)) => {