about summary refs log tree commit diff
path: root/compiler/rustc_expand/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-09-01 20:03:55 +0000
committerbors <bors@rust-lang.org>2020-09-01 20:03:55 +0000
commit130359cb05246fcacdde61baa2613419ef6570c7 (patch)
treea802248bcafa66177364c0e296094a56fe88891d /compiler/rustc_expand/src
parenteb9e7c357e26bf41c47661720e46f4498de32b83 (diff)
parenta97dcfa3755990062fd7905370cddd3843541db0 (diff)
downloadrust-130359cb05246fcacdde61baa2613419ef6570c7.tar.gz
rust-130359cb05246fcacdde61baa2613419ef6570c7.zip
Auto merge of #76010 - Aaron1011:fix/cfg-generic-param, r=petrochenkov
Run cfg-stripping on generic parameters before invoking derive macros

Fixes #75930

This changes the tokens seen by a proc-macro. However, ising a `#[cfg]` attribute
on a generic paramter is unusual, and combining it with a proc-macro
derive is probably even more unusual. I don't expect this to cause any
breakage.
Diffstat (limited to 'compiler/rustc_expand/src')
-rw-r--r--compiler/rustc_expand/src/config.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/rustc_expand/src/config.rs b/compiler/rustc_expand/src/config.rs
index afd1e606402..97608a38903 100644
--- a/compiler/rustc_expand/src/config.rs
+++ b/compiler/rustc_expand/src/config.rs
@@ -403,10 +403,6 @@ impl<'a> StripUnconfigured<'a> {
         items.flat_map_in_place(|item| self.configure(item));
     }
 
-    pub fn configure_generic_params(&mut self, params: &mut Vec<ast::GenericParam>) {
-        params.flat_map_in_place(|param| self.configure(param));
-    }
-
     fn configure_variant_data(&mut self, vdata: &mut ast::VariantData) {
         match vdata {
             ast::VariantData::Struct(fields, ..) | ast::VariantData::Tuple(fields, _) => {
@@ -496,6 +492,13 @@ impl<'a> MutVisitor for StripUnconfigured<'a> {
         Some(expr)
     }
 
+    fn flat_map_generic_param(
+        &mut self,
+        param: ast::GenericParam,
+    ) -> SmallVec<[ast::GenericParam; 1]> {
+        noop_flat_map_generic_param(configure!(self, param), self)
+    }
+
     fn flat_map_stmt(&mut self, stmt: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> {
         noop_flat_map_stmt(configure!(self, stmt), self)
     }