hygiene: Do not reset expansion info for quote!
This commit is contained in:
@@ -85,9 +85,6 @@ impl ProcMacro for Quoter {
|
|||||||
_: ::syntax_pos::Span,
|
_: ::syntax_pos::Span,
|
||||||
stream: tokenstream::TokenStream)
|
stream: tokenstream::TokenStream)
|
||||||
-> tokenstream::TokenStream {
|
-> tokenstream::TokenStream {
|
||||||
let mut info = cx.current_expansion.mark.expn_info().unwrap();
|
|
||||||
info.callee.allow_internal_unstable = true;
|
|
||||||
cx.current_expansion.mark.set_expn_info(info);
|
|
||||||
::__internal::set_sess(cx, || TokenStream(stream).quote().0)
|
::__internal::set_sess(cx, || TokenStream(stream).quote().0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -570,7 +570,7 @@ impl<'a> CrateLoader<'a> {
|
|||||||
name: &str,
|
name: &str,
|
||||||
expand: fn(TokenStream) -> TokenStream) {
|
expand: fn(TokenStream) -> TokenStream) {
|
||||||
let expand = SyntaxExtension::ProcMacro(
|
let expand = SyntaxExtension::ProcMacro(
|
||||||
Box::new(BangProcMacro { inner: expand }), self.edition
|
Box::new(BangProcMacro { inner: expand }), false, self.edition
|
||||||
);
|
);
|
||||||
self.extensions.push((Symbol::intern(name), Lrc::new(expand)));
|
self.extensions.push((Symbol::intern(name), Lrc::new(expand)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -519,7 +519,7 @@ impl CrateStore for cstore::CStore {
|
|||||||
} else if data.name == "proc_macro" &&
|
} else if data.name == "proc_macro" &&
|
||||||
self.get_crate_data(id.krate).item_name(id.index) == "quote" {
|
self.get_crate_data(id.krate).item_name(id.index) == "quote" {
|
||||||
let ext = SyntaxExtension::ProcMacro(Box::new(::proc_macro::__internal::Quoter),
|
let ext = SyntaxExtension::ProcMacro(Box::new(::proc_macro::__internal::Quoter),
|
||||||
data.root.edition);
|
true, data.root.edition);
|
||||||
return LoadedMacro::ProcMacro(Lrc::new(ext));
|
return LoadedMacro::ProcMacro(Lrc::new(ext));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -597,7 +597,11 @@ pub enum SyntaxExtension {
|
|||||||
MultiModifier(Box<MultiItemModifier + sync::Sync + sync::Send>),
|
MultiModifier(Box<MultiItemModifier + sync::Sync + sync::Send>),
|
||||||
|
|
||||||
/// A function-like procedural macro. TokenStream -> TokenStream.
|
/// A function-like procedural macro. TokenStream -> TokenStream.
|
||||||
ProcMacro(Box<ProcMacro + sync::Sync + sync::Send>, Edition),
|
ProcMacro(
|
||||||
|
/* expander: */ Box<ProcMacro + sync::Sync + sync::Send>,
|
||||||
|
/* allow_internal_unstable: */ bool,
|
||||||
|
/* edition: */ Edition,
|
||||||
|
),
|
||||||
|
|
||||||
/// An attribute-like procedural macro. TokenStream, TokenStream -> TokenStream.
|
/// An attribute-like procedural macro. TokenStream, TokenStream -> TokenStream.
|
||||||
/// The first TokenSteam is the attribute, the second is the annotated item.
|
/// The first TokenSteam is the attribute, the second is the annotated item.
|
||||||
|
|||||||
@@ -804,7 +804,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
|||||||
kind.dummy(span)
|
kind.dummy(span)
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcMacro(ref expandfun, edition) => {
|
ProcMacro(ref expandfun, allow_internal_unstable, edition) => {
|
||||||
if ident.name != keywords::Invalid.name() {
|
if ident.name != keywords::Invalid.name() {
|
||||||
let msg =
|
let msg =
|
||||||
format!("macro {}! expects no ident argument, given '{}'", path, ident);
|
format!("macro {}! expects no ident argument, given '{}'", path, ident);
|
||||||
@@ -821,7 +821,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
|||||||
// yet, when they do, we should use it here.
|
// yet, when they do, we should use it here.
|
||||||
span: None,
|
span: None,
|
||||||
// FIXME probably want to follow macro_rules macros here.
|
// FIXME probably want to follow macro_rules macros here.
|
||||||
allow_internal_unstable: false,
|
allow_internal_unstable,
|
||||||
allow_internal_unsafe: false,
|
allow_internal_unsafe: false,
|
||||||
edition,
|
edition,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user