Skip to content

Commit 5474f17

Browse files
committed
Remove hir::ImplItem::attrs.
1 parent c49359a commit 5474f17

File tree

13 files changed

+23
-36
lines changed

13 files changed

+23
-36
lines changed

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,10 +931,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
931931
let has_value = true;
932932
let (defaultness, _) = self.lower_defaultness(i.kind.defaultness(), has_value);
933933
let hir_id = self.lower_node_id(i.id);
934+
self.lower_attrs(hir_id, &i.attrs);
934935
hir::ImplItem {
935936
def_id: hir_id.expect_owner(),
936937
ident: i.ident,
937-
attrs: self.lower_attrs(hir_id, &i.attrs),
938938
generics,
939939
vis: self.lower_visibility(&i.vis, None),
940940
defaultness,

compiler/rustc_hir/src/hir.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,7 +2090,6 @@ pub struct ImplItem<'hir> {
20902090
pub def_id: LocalDefId,
20912091
pub vis: Visibility<'hir>,
20922092
pub defaultness: Defaultness,
2093-
pub attrs: &'hir [Attribute],
20942093
pub generics: Generics<'hir>,
20952094
pub kind: ImplItemKind<'hir>,
20962095
pub span: Span,
@@ -3080,6 +3079,6 @@ mod size_asserts {
30803079

30813080
rustc_data_structures::static_assert_size!(super::Item<'static>, 200);
30823081
rustc_data_structures::static_assert_size!(super::TraitItem<'static>, 128);
3083-
rustc_data_structures::static_assert_size!(super::ImplItem<'static>, 168);
3082+
rustc_data_structures::static_assert_size!(super::ImplItem<'static>, 152);
30843083
rustc_data_structures::static_assert_size!(super::ForeignItem<'static>, 136);
30853084
}

compiler/rustc_hir/src/intravisit.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -988,16 +988,8 @@ pub fn walk_trait_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, trait_item_ref:
988988

989989
pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplItem<'v>) {
990990
// N.B., deliberately force a compilation error if/when new fields are added.
991-
let ImplItem {
992-
def_id: _,
993-
ident,
994-
ref vis,
995-
ref defaultness,
996-
attrs: _,
997-
ref generics,
998-
ref kind,
999-
span: _,
1000-
} = *impl_item;
991+
let ImplItem { def_id: _, ident, ref vis, ref defaultness, ref generics, ref kind, span: _ } =
992+
*impl_item;
1001993

1002994
visitor.visit_ident(ident);
1003995
visitor.visit_vis(vis);

compiler/rustc_hir/src/stable_hash_impls.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,22 +152,13 @@ impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for TraitItem<'_> {
152152

153153
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for ImplItem<'_> {
154154
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
155-
let ImplItem {
156-
def_id: _,
157-
ident,
158-
ref vis,
159-
defaultness,
160-
ref attrs,
161-
ref generics,
162-
ref kind,
163-
span,
164-
} = *self;
155+
let ImplItem { def_id: _, ident, ref vis, defaultness, ref generics, ref kind, span } =
156+
*self;
165157

166158
hcx.hash_hir_item_like(|hcx| {
167159
ident.name.hash_stable(hcx, hasher);
168160
vis.hash_stable(hcx, hasher);
169161
defaultness.hash_stable(hcx, hasher);
170-
attrs.hash_stable(hcx, hasher);
171162
generics.hash_stable(hcx, hasher);
172163
kind.hash_stable(hcx, hasher);
173164
span.hash_stable(hcx, hasher);

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ impl<'a> State<'a> {
988988
self.ann.pre(self, AnnNode::SubItem(ii.hir_id()));
989989
self.hardbreak_if_not_bol();
990990
self.maybe_print_comment(ii.span.lo());
991-
self.print_outer_attributes(&ii.attrs);
991+
self.print_outer_attributes(self.attrs(ii.hir_id()));
992992
self.print_defaultness(ii.defaultness);
993993

994994
match ii.kind {

compiler/rustc_save_analysis/src/dump_visitor.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,14 +1067,15 @@ impl<'tcx> DumpVisitor<'tcx> {
10671067
match impl_item.kind {
10681068
hir::ImplItemKind::Const(ref ty, body) => {
10691069
let body = self.tcx.hir().body(body);
1070+
let attrs = self.tcx.hir().attrs(impl_item.hir_id());
10701071
self.process_assoc_const(
10711072
impl_item.hir_id(),
10721073
impl_item.ident,
10731074
&ty,
10741075
Some(&body.value),
10751076
impl_id,
10761077
&impl_item.vis,
1077-
&impl_item.attrs,
1078+
attrs,
10781079
);
10791080
}
10801081
hir::ImplItemKind::Fn(ref sig, body) => {

compiler/rustc_save_analysis/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,9 @@ impl<'tcx> SaveContext<'tcx> {
426426
let trait_id = self.tcx.trait_id_of_impl(impl_id);
427427
let mut docs = String::new();
428428
let mut attrs = vec![];
429-
if let Some(Node::ImplItem(item)) = hir.find(hir_id) {
430-
docs = self.docs_for_attrs(&item.attrs);
431-
attrs = item.attrs.to_vec();
429+
if let Some(Node::ImplItem(_)) = hir.find(hir_id) {
430+
attrs = self.tcx.hir().attrs(hir_id).to_vec();
431+
docs = self.docs_for_attrs(&attrs);
432432
}
433433

434434
let mut decl_id = None;

src/tools/clippy/clippy_lints/src/attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
353353

354354
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
355355
if is_relevant_impl(cx, item) {
356-
check_attrs(cx, item.span, item.ident.name, &item.attrs)
356+
check_attrs(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id()))
357357
}
358358
}
359359

src/tools/clippy/clippy_lints/src/doc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
260260
}
261261

262262
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<'_>) {
263-
let headers = check_attrs(cx, &self.valid_idents, &item.attrs);
263+
let attrs = cx.tcx.hir().attrs(item.hir_id());
264+
let headers = check_attrs(cx, &self.valid_idents, attrs);
264265
if self.in_trait_impl || in_external_macro(cx.tcx.sess, item.span) {
265266
return;
266267
}

src/tools/clippy/clippy_lints/src/functions.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,12 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
312312
if is_public && trait_ref_of_method(cx, item.hir_id()).is_none() {
313313
check_result_unit_err(cx, &sig.decl, item.span, fn_header_span);
314314
}
315-
let attr = must_use_attr(&item.attrs);
315+
let attrs = cx.tcx.hir().attrs(item.hir_id());
316+
let attr = must_use_attr(attrs);
316317
if let Some(attr) = attr {
317318
check_needless_must_use(cx, &sig.decl, item.hir_id(), item.span, fn_header_span, attr);
318319
} else if is_public
319-
&& !is_proc_macro(cx.sess(), &item.attrs)
320+
&& !is_proc_macro(cx.sess(), attrs)
320321
&& trait_ref_of_method(cx, item.hir_id()).is_none()
321322
{
322323
check_must_use_candidate(

0 commit comments

Comments
 (0)