Remove hir::Local::attrs.

This commit is contained in:
Camille GILLOT 2020-11-25 22:45:24 +01:00
parent ff79ad394f
commit 7ea1eacb17
3 changed files with 3 additions and 14 deletions

View File

@ -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::<Vec<_>>();
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::<Vec<_>>().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)))
}

View File

@ -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,

View File

@ -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;