Skip to content

Commit

Permalink
syntax: Remove SyntaxExtension::IdentTT and IdentMacroExpander
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Jun 10, 2019
1 parent a73ecb3 commit 97f4e70
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 64 deletions.
5 changes: 1 addition & 4 deletions src/librustc_plugin/registry.rs
Expand Up @@ -4,7 +4,7 @@ use rustc::lint::{EarlyLintPassObject, LateLintPassObject, LintId, Lint};
use rustc::session::Session;
use rustc::util::nodemap::FxHashMap;

use syntax::ext::base::{SyntaxExtension, NamedSyntaxExtension, NormalTT, IdentTT};
use syntax::ext::base::{SyntaxExtension, NamedSyntaxExtension, NormalTT};
use syntax::ext::base::MacroExpanderFn;
use syntax::symbol::{Symbol, sym};
use syntax::ast;
Expand Down Expand Up @@ -109,9 +109,6 @@ impl<'a> Registry<'a> {
edition,
}
}
IdentTT { expander, span: _, allow_internal_unstable } => {
IdentTT { expander, span: Some(self.krate_span), allow_internal_unstable }
}
_ => extension,
}));
}
Expand Down
38 changes: 0 additions & 38 deletions src/libsyntax/ext/base.rs
Expand Up @@ -288,34 +288,6 @@ impl<F> TTMacroExpander for F
}
}

pub trait IdentMacroExpander {
fn expand<'cx>(&self,
cx: &'cx mut ExtCtxt<'_>,
sp: Span,
ident: ast::Ident,
token_tree: Vec<tokenstream::TokenTree>)
-> Box<dyn MacResult+'cx>;
}

pub type IdentMacroExpanderFn =
for<'cx> fn(&'cx mut ExtCtxt<'_>, Span, ast::Ident, Vec<tokenstream::TokenTree>)
-> Box<dyn MacResult+'cx>;

impl<F> IdentMacroExpander for F
where F : for<'cx> Fn(&'cx mut ExtCtxt<'_>, Span, ast::Ident,
Vec<tokenstream::TokenTree>) -> Box<dyn MacResult+'cx>
{
fn expand<'cx>(&self,
cx: &'cx mut ExtCtxt<'_>,
sp: Span,
ident: ast::Ident,
token_tree: Vec<tokenstream::TokenTree>)
-> Box<dyn MacResult+'cx>
{
(*self)(cx, sp, ident, token_tree)
}
}

// Use a macro because forwarding to a simple function has type system issues
macro_rules! make_stmts_default {
($me:expr) => {
Expand Down Expand Up @@ -658,14 +630,6 @@ pub enum SyntaxExtension {
edition: Edition,
},

/// A function-like syntax extension that has an extra ident before
/// the block.
IdentTT {
expander: Box<dyn IdentMacroExpander + sync::Sync + sync::Send>,
span: Option<Span>,
allow_internal_unstable: Option<Lrc<[Symbol]>>,
},

/// An attribute-like procedural macro. TokenStream -> TokenStream.
/// The input is the annotated item.
/// Allows generating code to implement a Trait for a given struct
Expand All @@ -691,7 +655,6 @@ impl SyntaxExtension {
match *self {
SyntaxExtension::DeclMacro { .. } |
SyntaxExtension::NormalTT { .. } |
SyntaxExtension::IdentTT { .. } |
SyntaxExtension::ProcMacro { .. } =>
MacroKind::Bang,
SyntaxExtension::NonMacroAttr { .. } |
Expand Down Expand Up @@ -725,7 +688,6 @@ impl SyntaxExtension {
SyntaxExtension::ProcMacroDerive(.., edition) => edition,
// Unstable legacy stuff
SyntaxExtension::NonMacroAttr { .. } |
SyntaxExtension::IdentTT { .. } |
SyntaxExtension::MultiDecorator(..) |
SyntaxExtension::MultiModifier(..) |
SyntaxExtension::BuiltinDerive(..) => default_edition,
Expand Down
22 changes: 0 additions & 22 deletions src/libsyntax/ext/expand.rs
Expand Up @@ -791,28 +791,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
}
}

IdentTT { ref expander, span: tt_span, ref allow_internal_unstable } => {
if ident.name == kw::Invalid {
self.cx.span_err(path.span,
&format!("macro {}! expects an ident argument", path));
self.cx.trace_macros_diag();
kind.dummy(span)
} else {
invoc.expansion_data.mark.set_expn_info(ExpnInfo {
call_site: span,
def_site: tt_span,
format: macro_bang_format(path),
allow_internal_unstable: allow_internal_unstable.clone(),
allow_internal_unsafe: false,
local_inner_macros: false,
edition: self.cx.parse_sess.edition,
});

let input: Vec<_> = mac.node.stream().into_trees().collect();
kind.make_from(expander.expand(self.cx, span, ident, input))
}
}

MultiDecorator(..) | MultiModifier(..) |
AttrProcMacro(..) | SyntaxExtension::NonMacroAttr { .. } => {
self.cx.span_err(path.span,
Expand Down

0 comments on commit 97f4e70

Please sign in to comment.