Skip to content

Commit 7e16e1e

Browse files
committed
Access attrs directly from HirId in rustc_lint::levels.
1 parent b84bdf1 commit 7e16e1e

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

compiler/rustc_lint/src/levels.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -566,11 +566,12 @@ struct LintLevelMapBuilder<'a, 'tcx> {
566566
}
567567

568568
impl LintLevelMapBuilder<'_, '_> {
569-
fn with_lint_attrs<F>(&mut self, id: hir::HirId, attrs: &[ast::Attribute], f: F)
569+
fn with_lint_attrs<F>(&mut self, id: hir::HirId, f: F)
570570
where
571571
F: FnOnce(&mut Self),
572572
{
573573
let is_crate_hir = id == hir::CRATE_HIR_ID;
574+
let attrs = self.tcx.hir().attrs(id);
574575
let push = self.levels.push(attrs, self.store, is_crate_hir);
575576
if push.changed {
576577
self.levels.register_id(id);
@@ -588,19 +589,19 @@ impl<'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'_, 'tcx> {
588589
}
589590

590591
fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) {
591-
self.with_lint_attrs(param.hir_id, &param.attrs, |builder| {
592+
self.with_lint_attrs(param.hir_id, |builder| {
592593
intravisit::walk_param(builder, param);
593594
});
594595
}
595596

596597
fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
597-
self.with_lint_attrs(it.hir_id(), &it.attrs, |builder| {
598+
self.with_lint_attrs(it.hir_id(), |builder| {
598599
intravisit::walk_item(builder, it);
599600
});
600601
}
601602

602603
fn visit_foreign_item(&mut self, it: &'tcx hir::ForeignItem<'tcx>) {
603-
self.with_lint_attrs(it.hir_id(), &it.attrs, |builder| {
604+
self.with_lint_attrs(it.hir_id(), |builder| {
604605
intravisit::walk_foreign_item(builder, it);
605606
})
606607
}
@@ -613,13 +614,13 @@ impl<'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'_, 'tcx> {
613614
}
614615

615616
fn visit_expr(&mut self, e: &'tcx hir::Expr<'tcx>) {
616-
self.with_lint_attrs(e.hir_id, &e.attrs, |builder| {
617+
self.with_lint_attrs(e.hir_id, |builder| {
617618
intravisit::walk_expr(builder, e);
618619
})
619620
}
620621

621622
fn visit_struct_field(&mut self, s: &'tcx hir::StructField<'tcx>) {
622-
self.with_lint_attrs(s.hir_id, &s.attrs, |builder| {
623+
self.with_lint_attrs(s.hir_id, |builder| {
623624
intravisit::walk_struct_field(builder, s);
624625
})
625626
}
@@ -630,31 +631,31 @@ impl<'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'_, 'tcx> {
630631
g: &'tcx hir::Generics<'tcx>,
631632
item_id: hir::HirId,
632633
) {
633-
self.with_lint_attrs(v.id, &v.attrs, |builder| {
634+
self.with_lint_attrs(v.id, |builder| {
634635
intravisit::walk_variant(builder, v, g, item_id);
635636
})
636637
}
637638

638639
fn visit_local(&mut self, l: &'tcx hir::Local<'tcx>) {
639-
self.with_lint_attrs(l.hir_id, &l.attrs, |builder| {
640+
self.with_lint_attrs(l.hir_id, |builder| {
640641
intravisit::walk_local(builder, l);
641642
})
642643
}
643644

644645
fn visit_arm(&mut self, a: &'tcx hir::Arm<'tcx>) {
645-
self.with_lint_attrs(a.hir_id, &a.attrs, |builder| {
646+
self.with_lint_attrs(a.hir_id, |builder| {
646647
intravisit::walk_arm(builder, a);
647648
})
648649
}
649650

650651
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
651-
self.with_lint_attrs(trait_item.hir_id(), &trait_item.attrs, |builder| {
652+
self.with_lint_attrs(trait_item.hir_id(), |builder| {
652653
intravisit::walk_trait_item(builder, trait_item);
653654
});
654655
}
655656

656657
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) {
657-
self.with_lint_attrs(impl_item.hir_id(), &impl_item.attrs, |builder| {
658+
self.with_lint_attrs(impl_item.hir_id(), |builder| {
658659
intravisit::walk_impl_item(builder, impl_item);
659660
});
660661
}

0 commit comments

Comments
 (0)