syntax: Remove SyntaxExtension::IdentTT and IdentMacroExpander
This commit is contained in:
@@ -4,7 +4,7 @@ use rustc::lint::{EarlyLintPassObject, LateLintPassObject, LintId, Lint};
|
|||||||
use rustc::session::Session;
|
use rustc::session::Session;
|
||||||
use rustc::util::nodemap::FxHashMap;
|
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::ext::base::MacroExpanderFn;
|
||||||
use syntax::symbol::{Symbol, sym};
|
use syntax::symbol::{Symbol, sym};
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
@@ -109,9 +109,6 @@ impl<'a> Registry<'a> {
|
|||||||
edition,
|
edition,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IdentTT { expander, span: _, allow_internal_unstable } => {
|
|
||||||
IdentTT { expander, span: Some(self.krate_span), allow_internal_unstable }
|
|
||||||
}
|
|
||||||
_ => extension,
|
_ => extension,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
// Use a macro because forwarding to a simple function has type system issues
|
||||||
macro_rules! make_stmts_default {
|
macro_rules! make_stmts_default {
|
||||||
($me:expr) => {
|
($me:expr) => {
|
||||||
@@ -658,14 +630,6 @@ pub enum SyntaxExtension {
|
|||||||
edition: Edition,
|
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.
|
/// An attribute-like procedural macro. TokenStream -> TokenStream.
|
||||||
/// The input is the annotated item.
|
/// The input is the annotated item.
|
||||||
/// Allows generating code to implement a Trait for a given struct
|
/// Allows generating code to implement a Trait for a given struct
|
||||||
@@ -691,7 +655,6 @@ impl SyntaxExtension {
|
|||||||
match *self {
|
match *self {
|
||||||
SyntaxExtension::DeclMacro { .. } |
|
SyntaxExtension::DeclMacro { .. } |
|
||||||
SyntaxExtension::NormalTT { .. } |
|
SyntaxExtension::NormalTT { .. } |
|
||||||
SyntaxExtension::IdentTT { .. } |
|
|
||||||
SyntaxExtension::ProcMacro { .. } =>
|
SyntaxExtension::ProcMacro { .. } =>
|
||||||
MacroKind::Bang,
|
MacroKind::Bang,
|
||||||
SyntaxExtension::NonMacroAttr { .. } |
|
SyntaxExtension::NonMacroAttr { .. } |
|
||||||
@@ -725,7 +688,6 @@ impl SyntaxExtension {
|
|||||||
SyntaxExtension::ProcMacroDerive(.., edition) => edition,
|
SyntaxExtension::ProcMacroDerive(.., edition) => edition,
|
||||||
// Unstable legacy stuff
|
// Unstable legacy stuff
|
||||||
SyntaxExtension::NonMacroAttr { .. } |
|
SyntaxExtension::NonMacroAttr { .. } |
|
||||||
SyntaxExtension::IdentTT { .. } |
|
|
||||||
SyntaxExtension::MultiDecorator(..) |
|
SyntaxExtension::MultiDecorator(..) |
|
||||||
SyntaxExtension::MultiModifier(..) |
|
SyntaxExtension::MultiModifier(..) |
|
||||||
SyntaxExtension::BuiltinDerive(..) => default_edition,
|
SyntaxExtension::BuiltinDerive(..) => default_edition,
|
||||||
|
|||||||
@@ -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(..) |
|
MultiDecorator(..) | MultiModifier(..) |
|
||||||
AttrProcMacro(..) | SyntaxExtension::NonMacroAttr { .. } => {
|
AttrProcMacro(..) | SyntaxExtension::NonMacroAttr { .. } => {
|
||||||
self.cx.span_err(path.span,
|
self.cx.span_err(path.span,
|
||||||
|
|||||||
Reference in New Issue
Block a user