refactor Method definition to make space for macros

This change propagates to many locations, but because of the
Macro Exterminator (or, more properly, the invariant that it
protects), macro invocations can't occur downstream of expansion.
This means that in librustc and librustdoc, extracting the
desired field can simply assume that it can't be a macro
invocation. Functions in ast_util abstract over this check.
This commit is contained in:
John Clements
2014-07-11 21:22:11 -07:00
parent e178ebf681
commit b0b4b3122a
25 changed files with 277 additions and 173 deletions

View File

@@ -794,16 +794,21 @@ pub fn noop_fold_foreign_item<T: Folder>(ni: &ForeignItem,
pub fn noop_fold_method<T: Folder>(m: &Method, folder: &mut T) -> Gc<Method> {
let id = folder.new_id(m.id); // Needs to be first, for ast_map.
box(GC) Method {
id: id,
ident: folder.fold_ident(m.ident),
attrs: m.attrs.iter().map(|a| folder.fold_attribute(*a)).collect(),
generics: fold_generics(&m.generics, folder),
explicit_self: folder.fold_explicit_self(&m.explicit_self),
fn_style: m.fn_style,
decl: folder.fold_fn_decl(&*m.decl),
body: folder.fold_block(m.body),
id: id,
span: folder.new_span(m.span),
vis: m.vis
node: match m.node {
MethDecl(ident, ref generics, ref explicit_self, fn_style, decl, body, vis) => {
MethDecl(folder.fold_ident(ident),
fold_generics(generics, folder),
folder.fold_explicit_self(explicit_self),
fn_style,
folder.fold_fn_decl(&*decl),
folder.fold_block(body),
vis)
},
MethMac(ref mac) => MethMac(folder.fold_mac(mac)),
}
}
}