cleanup: don't count attributes on an item in a statement position as on the statement
This commit is contained in:
parent
ea0dc92972
commit
b968ee3656
2 changed files with 3 additions and 8 deletions
|
@ -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)| {
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue