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.
This commit is contained in:
commit
130359cb05
3 changed files with 258 additions and 4 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue