Skip to content

Commit c00f5af

Browse files
committed
hygiene: Do not reset expansion info for quote!
1 parent fffe9fb commit c00f5af

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

src/libproc_macro/quote.rs

-3
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ impl ProcMacro for Quoter {
8585
_: ::syntax_pos::Span,
8686
stream: tokenstream::TokenStream)
8787
-> tokenstream::TokenStream {
88-
let mut info = cx.current_expansion.mark.expn_info().unwrap();
89-
info.callee.allow_internal_unstable = true;
90-
cx.current_expansion.mark.set_expn_info(info);
9188
::__internal::set_sess(cx, || TokenStream(stream).quote().0)
9289
}
9390
}

src/librustc_metadata/creader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ impl<'a> CrateLoader<'a> {
570570
name: &str,
571571
expand: fn(TokenStream) -> TokenStream) {
572572
let expand = SyntaxExtension::ProcMacro(
573-
Box::new(BangProcMacro { inner: expand }), self.edition
573+
Box::new(BangProcMacro { inner: expand }), false, self.edition
574574
);
575575
self.extensions.push((Symbol::intern(name), Lrc::new(expand)));
576576
}

src/librustc_metadata/cstore_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ impl CrateStore for cstore::CStore {
519519
} else if data.name == "proc_macro" &&
520520
self.get_crate_data(id.krate).item_name(id.index) == "quote" {
521521
let ext = SyntaxExtension::ProcMacro(Box::new(::proc_macro::__internal::Quoter),
522-
data.root.edition);
522+
true, data.root.edition);
523523
return LoadedMacro::ProcMacro(Lrc::new(ext));
524524
}
525525

src/libsyntax/ext/base.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,11 @@ pub enum SyntaxExtension {
597597
MultiModifier(Box<MultiItemModifier + sync::Sync + sync::Send>),
598598

599599
/// A function-like procedural macro. TokenStream -> TokenStream.
600-
ProcMacro(Box<ProcMacro + sync::Sync + sync::Send>, Edition),
600+
ProcMacro(
601+
/* expander: */ Box<ProcMacro + sync::Sync + sync::Send>,
602+
/* allow_internal_unstable: */ bool,
603+
/* edition: */ Edition,
604+
),
601605

602606
/// An attribute-like procedural macro. TokenStream, TokenStream -> TokenStream.
603607
/// The first TokenSteam is the attribute, the second is the annotated item.

src/libsyntax/ext/expand.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
804804
kind.dummy(span)
805805
}
806806

807-
ProcMacro(ref expandfun, edition) => {
807+
ProcMacro(ref expandfun, allow_internal_unstable, edition) => {
808808
if ident.name != keywords::Invalid.name() {
809809
let msg =
810810
format!("macro {}! expects no ident argument, given '{}'", path, ident);
@@ -821,7 +821,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
821821
// yet, when they do, we should use it here.
822822
span: None,
823823
// FIXME probably want to follow macro_rules macros here.
824-
allow_internal_unstable: false,
824+
allow_internal_unstable,
825825
allow_internal_unsafe: false,
826826
edition,
827827
},

0 commit comments

Comments
 (0)