Skip to content

Commit

Permalink
expand: Remove redundant calls to configure
Browse files Browse the repository at this point in the history
Starting from rust-lang#63468 cfg attributes on variants, fields, fn params etc. are processed together with other attributes (via `configure!`).
  • Loading branch information
petrochenkov committed Feb 14, 2021
1 parent 18c94b3 commit 6e11a8b
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions compiler/rustc_expand/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1067,8 +1067,6 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
fn visit_expr(&mut self, expr: &mut P<ast::Expr>) {
self.cfg.configure_expr(expr);
visit_clobber(expr.deref_mut(), |mut expr| {
self.cfg.configure_expr_kind(&mut expr.kind);

if let Some(attr) = self.take_first_attr(&mut expr) {
// Collect the invoc regardless of whether or not attributes are permitted here
// expansion will eat the attribute so it won't error later.
Expand Down Expand Up @@ -1166,8 +1164,6 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
fn filter_map_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
let expr = configure!(self, expr);
expr.filter_map(|mut expr| {
self.cfg.configure_expr_kind(&mut expr.kind);

if let Some(attr) = self.take_first_attr(&mut expr) {
self.cfg.maybe_emit_expr_attr_err(&attr.0);

Expand All @@ -1192,7 +1188,6 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
}

fn visit_pat(&mut self, pat: &mut P<ast::Pat>) {
self.cfg.configure_pat(pat);
match pat.kind {
PatKind::MacCall(_) => {}
_ => return noop_visit_pat(pat, self),
Expand Down Expand Up @@ -1406,15 +1401,12 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
});
}

fn visit_foreign_mod(&mut self, foreign_mod: &mut ast::ForeignMod) {
self.cfg.configure_foreign_mod(foreign_mod);
noop_visit_foreign_mod(foreign_mod, self);
}

fn flat_map_foreign_item(
&mut self,
mut foreign_item: P<ast::ForeignItem>,
foreign_item: P<ast::ForeignItem>,
) -> SmallVec<[P<ast::ForeignItem>; 1]> {
let mut foreign_item = configure!(self, foreign_item);

if let Some(attr) = self.take_first_attr(&mut foreign_item) {
return self
.collect_attr(
Expand All @@ -1439,11 +1431,6 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
}
}

fn visit_item_kind(&mut self, item: &mut ast::ItemKind) {
self.cfg.configure_item_kind(item);
noop_visit_item_kind(item, self);
}

fn flat_map_generic_param(
&mut self,
param: ast::GenericParam,
Expand Down Expand Up @@ -1602,11 +1589,6 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
*id = self.cx.resolver.next_node_id()
}
}

fn visit_fn_decl(&mut self, mut fn_decl: &mut P<ast::FnDecl>) {
self.cfg.configure_fn_decl(&mut fn_decl);
noop_visit_fn_decl(fn_decl, self);
}
}

pub struct ExpansionConfig<'feat> {
Expand Down

0 comments on commit 6e11a8b

Please sign in to comment.