Skip to content

Commit

Permalink
Rollup merge of rust-lang#43712 - oli-obk:cfg, r=arielb1
Browse files Browse the repository at this point in the history
Reexport all SyntaxExtension variants

This was previously done very inconsistently and made matches look weird since some variants had the `SyntaxExtension::` prefix while others didn't.
  • Loading branch information
MaloJaffre authored Aug 11, 2017
2 parents 9dba107 + 970c780 commit 37511aa
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/libsyntax/ext/base.rs
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

pub use self::SyntaxExtension::{MultiDecorator, MultiModifier, NormalTT, IdentTT};
pub use self::SyntaxExtension::*;

use ast::{self, Attribute, Name, PatKind, MetaItem};
use attr::HasAttrs;
18 changes: 9 additions & 9 deletions src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
@@ -294,7 +294,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
let item = match self.cx.resolver.resolve_macro(
Mark::root(), path, MacroKind::Derive, false) {
Ok(ext) => match *ext {
SyntaxExtension::BuiltinDerive(..) => item_with_markers.clone(),
BuiltinDerive(..) => item_with_markers.clone(),
_ => item.clone(),
},
_ => item.clone(),
@@ -427,7 +427,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
items.push(item);
kind.expect_from_annotatables(items)
}
SyntaxExtension::AttrProcMacro(ref mac) => {
AttrProcMacro(ref mac) => {
let item_tok = TokenTree::Token(DUMMY_SP, Token::interpolated(match item {
Annotatable::Item(item) => token::NtItem(item),
Annotatable::TraitItem(item) => token::NtTraitItem(item.unwrap()),
@@ -436,7 +436,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
let tok_result = mac.expand(self.cx, attr.span, attr.tokens, item_tok);
self.parse_expansion(tok_result, kind, &attr.path, attr.span)
}
SyntaxExtension::ProcMacroDerive(..) | SyntaxExtension::BuiltinDerive(..) => {
ProcMacroDerive(..) | BuiltinDerive(..) => {
self.cx.span_err(attr.span, &format!("`{}` is a derive mode", attr.path));
kind.dummy(attr.span)
}
@@ -474,7 +474,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
};

let opt_expanded = match *ext {
SyntaxExtension::DeclMacro(ref expand, def_span) => {
DeclMacro(ref expand, def_span) => {
if let Err(msg) = validate_and_set_expn_info(def_span.map(|(_, s)| s),
false) {
self.cx.span_err(path.span, &msg);
@@ -512,18 +512,18 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
kind.make_from(expander.expand(self.cx, span, ident, input))
}

MultiDecorator(..) | MultiModifier(..) | SyntaxExtension::AttrProcMacro(..) => {
MultiDecorator(..) | MultiModifier(..) | AttrProcMacro(..) => {
self.cx.span_err(path.span,
&format!("`{}` can only be used in attributes", path));
return kind.dummy(span);
}

SyntaxExtension::ProcMacroDerive(..) | SyntaxExtension::BuiltinDerive(..) => {
ProcMacroDerive(..) | BuiltinDerive(..) => {
self.cx.span_err(path.span, &format!("`{}` is a derive mode", path));
return kind.dummy(span);
}

SyntaxExtension::ProcMacro(ref expandfun) => {
ProcMacro(ref expandfun) => {
if ident.name != keywords::Invalid.name() {
let msg =
format!("macro {}! expects no ident argument, given '{}'", path, ident);
@@ -582,7 +582,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
};

match *ext {
SyntaxExtension::ProcMacroDerive(ref ext, _) => {
ProcMacroDerive(ref ext, _) => {
invoc.expansion_data.mark.set_expn_info(expn_info);
let span = Span { ctxt: self.cx.backtrace(), ..span };
let dummy = ast::MetaItem { // FIXME(jseyfried) avoid this
@@ -592,7 +592,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
};
kind.expect_from_annotatables(ext.expand(self.cx, span, &dummy, item))
}
SyntaxExtension::BuiltinDerive(func) => {
BuiltinDerive(func) => {
expn_info.callee.allow_internal_unstable = true;
invoc.expansion_data.mark.set_expn_info(expn_info);
let span = Span { ctxt: self.cx.backtrace(), ..span };

0 comments on commit 37511aa

Please # to comment.