Skip to content

Commit b968ee3

Browse files
committed
cleanup: don't count attributes on an item in a statement position as on the statement
1 parent ea0dc92 commit b968ee3

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

src/libsyntax/attr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ impl HasAttrs for StmtKind {
839839
fn attrs(&self) -> &[Attribute] {
840840
match *self {
841841
StmtKind::Local(ref local) => local.attrs(),
842-
StmtKind::Item(ref item) => item.attrs(),
842+
StmtKind::Item(..) => &[],
843843
StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => expr.attrs(),
844844
StmtKind::Mac(ref mac) => {
845845
let (_, _, ref attrs) = **mac;
@@ -851,7 +851,7 @@ impl HasAttrs for StmtKind {
851851
fn map_attrs<F: FnOnce(Vec<Attribute>) -> Vec<Attribute>>(self, f: F) -> Self {
852852
match self {
853853
StmtKind::Local(local) => StmtKind::Local(local.map_attrs(f)),
854-
StmtKind::Item(item) => StmtKind::Item(item.map_attrs(f)),
854+
StmtKind::Item(..) => self,
855855
StmtKind::Expr(expr) => StmtKind::Expr(expr.map_attrs(f)),
856856
StmtKind::Semi(expr) => StmtKind::Semi(expr.map_attrs(f)),
857857
StmtKind::Mac(mac) => StmtKind::Mac(mac.map(|(mac, style, attrs)| {

src/libsyntax/config.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,7 @@ impl<'a> fold::Folder for StripUnconfigured<'a> {
213213
}
214214

215215
fn fold_stmt(&mut self, stmt: ast::Stmt) -> SmallVector<ast::Stmt> {
216-
// avoid calling `visit_stmt_or_expr_attrs` on items
217-
match stmt.node {
218-
ast::StmtKind::Item(_) => {}
219-
_ => self.visit_stmt_or_expr_attrs(stmt.attrs()),
220-
}
221-
216+
self.visit_stmt_or_expr_attrs(stmt.attrs());
222217
self.configure(stmt).map(|stmt| fold::noop_fold_stmt(stmt, self))
223218
.unwrap_or(SmallVector::zero())
224219
}

0 commit comments

Comments
 (0)