diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index ac945a8903a8..653a3b3fda22 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1800,8 +1800,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { }); let init = l.init.as_ref().map(|e| self.lower_expr(e)); let hir_id = self.lower_node_id(l.id); - let attrs = l.attrs.iter().map(|a| self.lower_attr(a)).collect::>(); - self.attrs.push_sparse(hir_id, &*self.arena.alloc_from_iter(attrs.iter().cloned())); + self.lower_attrs(hir_id, &l.attrs); ( hir::Local { hir_id, @@ -1809,7 +1808,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { pat: self.lower_pat(&l.pat), init, span: l.span, - attrs: attrs.into(), source: hir::LocalSource::Normal, }, ids, @@ -2534,15 +2532,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { ) -> hir::Stmt<'hir> { let hir_id = self.next_id(); self.attrs.push_sparse(hir_id, attrs); - let local = hir::Local { - attrs: attrs.iter().cloned().collect::>().into(), - hir_id, - init, - pat, - source, - span, - ty: None, - }; + let local = hir::Local { hir_id, init, pat, source, span, ty: None }; self.stmt(span, hir::StmtKind::Local(self.arena.alloc(local))) } diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 03e56308be8e..ed7a1415c2a8 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -1179,7 +1179,6 @@ pub struct Local<'hir> { pub init: Option<&'hir Expr<'hir>>, pub hir_id: HirId, pub span: Span, - pub attrs: AttrVec, /// Can be `ForLoopDesugar` if the `let` statement is part of a `for` loop /// desugaring. Otherwise will be `Normal`. pub source: LocalSource, diff --git a/src/tools/clippy/clippy_lints/src/returns.rs b/src/tools/clippy/clippy_lints/src/returns.rs index 28d7011207f8..e8646695e0b2 100644 --- a/src/tools/clippy/clippy_lints/src/returns.rs +++ b/src/tools/clippy/clippy_lints/src/returns.rs @@ -81,7 +81,7 @@ impl<'tcx> LateLintPass<'tcx> for Return { if let Some(stmt) = block.stmts.iter().last(); if let StmtKind::Local(local) = &stmt.kind; if local.ty.is_none(); - if local.attrs.is_empty(); + if cx.tcx.hir().attrs(local.hir_id).is_empty(); if let Some(initexpr) = &local.init; if let PatKind::Binding(.., ident, _) = local.pat.kind; if let ExprKind::Path(qpath) = &retexpr.kind;