Skip to content

Commit 7ea1eac

Browse files
committed
Remove hir::Local::attrs.
1 parent ff79ad3 commit 7ea1eac

File tree

3 files changed

+3
-14
lines changed

3 files changed

+3
-14
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,16 +1800,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
18001800
});
18011801
let init = l.init.as_ref().map(|e| self.lower_expr(e));
18021802
let hir_id = self.lower_node_id(l.id);
1803-
let attrs = l.attrs.iter().map(|a| self.lower_attr(a)).collect::<Vec<_>>();
1804-
self.attrs.push_sparse(hir_id, &*self.arena.alloc_from_iter(attrs.iter().cloned()));
1803+
self.lower_attrs(hir_id, &l.attrs);
18051804
(
18061805
hir::Local {
18071806
hir_id,
18081807
ty,
18091808
pat: self.lower_pat(&l.pat),
18101809
init,
18111810
span: l.span,
1812-
attrs: attrs.into(),
18131811
source: hir::LocalSource::Normal,
18141812
},
18151813
ids,
@@ -2534,15 +2532,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
25342532
) -> hir::Stmt<'hir> {
25352533
let hir_id = self.next_id();
25362534
self.attrs.push_sparse(hir_id, attrs);
2537-
let local = hir::Local {
2538-
attrs: attrs.iter().cloned().collect::<Vec<_>>().into(),
2539-
hir_id,
2540-
init,
2541-
pat,
2542-
source,
2543-
span,
2544-
ty: None,
2545-
};
2535+
let local = hir::Local { hir_id, init, pat, source, span, ty: None };
25462536
self.stmt(span, hir::StmtKind::Local(self.arena.alloc(local)))
25472537
}
25482538

compiler/rustc_hir/src/hir.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,6 @@ pub struct Local<'hir> {
11791179
pub init: Option<&'hir Expr<'hir>>,
11801180
pub hir_id: HirId,
11811181
pub span: Span,
1182-
pub attrs: AttrVec,
11831182
/// Can be `ForLoopDesugar` if the `let` statement is part of a `for` loop
11841183
/// desugaring. Otherwise will be `Normal`.
11851184
pub source: LocalSource,

src/tools/clippy/clippy_lints/src/returns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl<'tcx> LateLintPass<'tcx> for Return {
8181
if let Some(stmt) = block.stmts.iter().last();
8282
if let StmtKind::Local(local) = &stmt.kind;
8383
if local.ty.is_none();
84-
if local.attrs.is_empty();
84+
if cx.tcx.hir().attrs(local.hir_id).is_empty();
8585
if let Some(initexpr) = &local.init;
8686
if let PatKind::Binding(.., ident, _) = local.pat.kind;
8787
if let ExprKind::Path(qpath) = &retexpr.kind;

0 commit comments

Comments
 (0)