]> git.lizzy.rs Git - rust.git/commitdiff
hygiene: Do not reset expansion info for `quote!`
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Sat, 23 Jun 2018 17:09:11 +0000 (20:09 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Sat, 23 Jun 2018 17:40:25 +0000 (20:40 +0300)
src/libproc_macro/quote.rs
src/librustc_metadata/creader.rs
src/librustc_metadata/cstore_impl.rs
src/libsyntax/ext/base.rs
src/libsyntax/ext/expand.rs

index c9d0bc1405fc01dcb17fcf6432590a0f32864786..4cd822aa9d0b969689318d6e08d2e850beea3ac3 100644 (file)
@@ -85,9 +85,6 @@ fn expand<'cx>(&self, cx: &'cx mut ExtCtxt,
                    _: ::syntax_pos::Span,
                    stream: 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)
     }
 }
index 6c1991457433f6231b445ea18632501afff5bdc7..1a13335a0e49d34bfc44b62f02b7011ecd4126b1 100644 (file)
@@ -570,7 +570,7 @@ fn register_bang_proc_macro(&mut self,
                                         name: &str,
                                         expand: fn(TokenStream) -> TokenStream) {
                 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)));
             }
index b33d97cb1ee9f7988d17e99bd8bf72f71ba75e64..d0e4e54e63d677f86f615ff5004b4620d3c5b644 100644 (file)
@@ -519,7 +519,7 @@ fn load_macro_untracked(&self, id: DefId, sess: &Session) -> LoadedMacro {
         } else if data.name == "proc_macro" &&
                   self.get_crate_data(id.krate).item_name(id.index) == "quote" {
             let ext = SyntaxExtension::ProcMacro(Box::new(::proc_macro::__internal::Quoter),
-                                                 data.root.edition);
+                                                 true, data.root.edition);
             return LoadedMacro::ProcMacro(Lrc::new(ext));
         }
 
index b7f4bc614354599e0ede0d1badf5a7eb8b5d88b0..e8fad1a2177717cd411e3ea58bd743ee3d4bb4da 100644 (file)
@@ -597,7 +597,11 @@ pub enum SyntaxExtension {
     MultiModifier(Box<MultiItemModifier + sync::Sync + sync::Send>),
 
     /// 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.
     /// The first TokenSteam is the attribute, the second is the annotated item.
index eb26bdc74b5e328d7602e708e43f514b4c570cc8..8ad6e32f42d9a365d3eafb3cf28bbfb458a90cd7 100644 (file)
@@ -804,7 +804,7 @@ fn expand_bang_invoc(&mut self,
                 kind.dummy(span)
             }
 
-            ProcMacro(ref expandfun, edition) => {
+            ProcMacro(ref expandfun, allow_internal_unstable, edition) => {
                 if ident.name != keywords::Invalid.name() {
                     let msg =
                         format!("macro {}! expects no ident argument, given '{}'", path, ident);
@@ -821,7 +821,7 @@ fn expand_bang_invoc(&mut self,
                             // yet, when they do, we should use it here.
                             span: None,
                             // FIXME probably want to follow macro_rules macros here.
-                            allow_internal_unstable: false,
+                            allow_internal_unstable,
                             allow_internal_unsafe: false,
                             edition,
                         },