diff options
| author | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-06-14 06:48:24 +0000 |
|---|---|---|
| committer | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-06-28 05:28:20 +0000 |
| commit | b968ee36564abd96da72c381f49bf8009f4b1870 (patch) | |
| tree | 73e6393ef767824453a1e2615eff47d00f3132c1 /src/libsyntax | |
| parent | ea0dc9297283daff6486807f43e190b4eb561412 (diff) | |
| download | rust-b968ee36564abd96da72c381f49bf8009f4b1870.tar.gz rust-b968ee36564abd96da72c381f49bf8009f4b1870.zip | |
cleanup: don't count attributes on an item in a statement position as on the statement
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/attr.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/config.rs | 7 |
2 files changed, 3 insertions, 8 deletions
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index da2967e306f..3c88fb8f670 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -839,7 +839,7 @@ impl HasAttrs for StmtKind { fn attrs(&self) -> &[Attribute] { match *self { StmtKind::Local(ref local) => local.attrs(), - StmtKind::Item(ref item) => item.attrs(), + StmtKind::Item(..) => &[], StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => expr.attrs(), StmtKind::Mac(ref mac) => { let (_, _, ref attrs) = **mac; @@ -851,7 +851,7 @@ impl HasAttrs for StmtKind { fn map_attrs<F: FnOnce(Vec<Attribute>) -> Vec<Attribute>>(self, f: F) -> Self { match self { StmtKind::Local(local) => StmtKind::Local(local.map_attrs(f)), - StmtKind::Item(item) => StmtKind::Item(item.map_attrs(f)), + StmtKind::Item(..) => self, StmtKind::Expr(expr) => StmtKind::Expr(expr.map_attrs(f)), StmtKind::Semi(expr) => StmtKind::Semi(expr.map_attrs(f)), StmtKind::Mac(mac) => StmtKind::Mac(mac.map(|(mac, style, attrs)| { diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 961763c6025..eaf82f5f43d 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -213,12 +213,7 @@ impl<'a> fold::Folder for StripUnconfigured<'a> { } fn fold_stmt(&mut self, stmt: ast::Stmt) -> SmallVector<ast::Stmt> { - // avoid calling `visit_stmt_or_expr_attrs` on items - match stmt.node { - ast::StmtKind::Item(_) => {} - _ => self.visit_stmt_or_expr_attrs(stmt.attrs()), - } - + self.visit_stmt_or_expr_attrs(stmt.attrs()); self.configure(stmt).map(|stmt| fold::noop_fold_stmt(stmt, self)) .unwrap_or(SmallVector::zero()) } |
