diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index df1bbf5f26e..596faac3588 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -35,10 +35,18 @@ use std::collections::HashSet; use std::env; +// A trait for AST nodes and AST node lists into which macro invocations may expand. trait MacroGenerable: Sized { + // Expand the given MacResult using its appropriate `make_*` method. fn make_with<'a>(result: Box) -> Option; + + // Fold this node or list of nodes using the given folder. fn fold_with(self, folder: &mut F) -> Self; + + // Return a placeholder expansion to allow compilation to continue after an erroring expansion. fn dummy(span: Span) -> Self; + + // The user-friendly name of the node type (e.g. "expression", "item", etc.) for diagnostics. fn kind_name() -> &'static str; } @@ -207,7 +215,7 @@ fn mac_result<'a>(path: &ast::Path, ident: Option, tts: Vec, m return None; }; - let ident = ident.unwrap_or(Ident::with_empty_ctxt(keywords::Invalid.name())); + let ident = ident.unwrap_or(keywords::Invalid.ident()); match *extension { NormalTT(ref expandfun, exp_span, allow_internal_unstable) => { if ident.name != keywords::Invalid.name() {