Skip to content

Commit 4bab93a

Browse files
committed
Remove hir::ForeignItem::attrs.
1 parent c298744 commit 4bab93a

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,10 +700,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
700700
fn lower_foreign_item(&mut self, i: &ForeignItem) -> hir::ForeignItem<'hir> {
701701
let hir_id = self.lower_node_id(i.id);
702702
let def_id = hir_id.expect_owner();
703+
self.lower_attrs(hir_id, &i.attrs);
703704
hir::ForeignItem {
704705
def_id,
705706
ident: i.ident,
706-
attrs: self.lower_attrs(hir_id, &i.attrs),
707707
kind: match i.kind {
708708
ForeignItemKind::Fn(box FnKind(_, ref sig, ref generics, _)) => {
709709
let fdec = &sig.decl;

compiler/rustc_hir/src/hir.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2916,7 +2916,6 @@ pub struct ForeignItemRef<'hir> {
29162916
#[derive(Debug)]
29172917
pub struct ForeignItem<'hir> {
29182918
pub ident: Ident,
2919-
pub attrs: &'hir [Attribute],
29202919
pub kind: ForeignItemKind<'hir>,
29212920
pub def_id: LocalDefId,
29222921
pub span: Span,
@@ -3083,5 +3082,5 @@ mod size_asserts {
30833082
rustc_data_structures::static_assert_size!(super::Item<'static>, 200);
30843083
rustc_data_structures::static_assert_size!(super::TraitItem<'static>, 144);
30853084
rustc_data_structures::static_assert_size!(super::ImplItem<'static>, 168);
3086-
rustc_data_structures::static_assert_size!(super::ForeignItem<'static>, 152);
3085+
rustc_data_structures::static_assert_size!(super::ForeignItem<'static>, 136);
30873086
}

compiler/rustc_hir/src/stable_hash_impls.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,10 @@ impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for ImplItem<'_> {
178178

179179
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for ForeignItem<'_> {
180180
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
181-
let ForeignItem { def_id: _, ident, ref attrs, ref kind, span, ref vis } = *self;
181+
let ForeignItem { def_id: _, ident, ref kind, span, ref vis } = *self;
182182

183183
hcx.hash_hir_item_like(|hcx| {
184184
ident.name.hash_stable(hcx, hasher);
185-
attrs.hash_stable(hcx, hasher);
186185
kind.hash_stable(hcx, hasher);
187186
span.hash_stable(hcx, hasher);
188187
vis.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
@@ -453,7 +453,7 @@ impl<'a> State<'a> {
453453
pub fn print_foreign_item(&mut self, item: &hir::ForeignItem<'_>) {
454454
self.hardbreak_if_not_bol();
455455
self.maybe_print_comment(item.span.lo());
456-
self.print_outer_attributes(&item.attrs);
456+
self.print_outer_attributes(self.attrs(item.hir_id()));
457457
match item.kind {
458458
hir::ForeignItemKind::Fn(ref decl, ref arg_names, ref generics) => {
459459
self.head("");

compiler/rustc_passes/src/weak_lang_items.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
9797

9898
fn visit_foreign_item(&mut self, i: &hir::ForeignItem<'_>) {
9999
let check_name = |attr, sym| self.tcx.sess.check_name(attr, sym);
100-
if let Some((lang_item, _)) = lang_items::extract(check_name, &i.attrs) {
100+
let attrs = self.tcx.hir().attrs(i.hir_id());
101+
if let Some((lang_item, _)) = lang_items::extract(check_name, attrs) {
101102
self.register(lang_item, i.span);
102103
}
103104
intravisit::walk_foreign_item(self, i)

compiler/rustc_save_analysis/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ impl<'tcx> SaveContext<'tcx> {
139139
pub fn get_extern_item_data(&self, item: &hir::ForeignItem<'_>) -> Option<Data> {
140140
let def_id = item.def_id.to_def_id();
141141
let qualname = format!("::{}", self.tcx.def_path_str(def_id));
142+
let attrs = self.tcx.hir().attrs(item.hir_id());
142143
match item.kind {
143144
hir::ForeignItemKind::Fn(ref decl, arg_names, ref generics) => {
144145
filter!(self.span_utils, item.ident.span);
@@ -169,9 +170,9 @@ impl<'tcx> SaveContext<'tcx> {
169170
parent: None,
170171
children: vec![],
171172
decl_id: None,
172-
docs: self.docs_for_attrs(&item.attrs),
173+
docs: self.docs_for_attrs(attrs),
173174
sig: sig::foreign_item_signature(item, self),
174-
attributes: lower_attributes(item.attrs.to_vec(), self),
175+
attributes: lower_attributes(attrs.to_vec(), self),
175176
}))
176177
}
177178
hir::ForeignItemKind::Static(ref ty, _) => {
@@ -190,9 +191,9 @@ impl<'tcx> SaveContext<'tcx> {
190191
parent: None,
191192
children: vec![],
192193
decl_id: None,
193-
docs: self.docs_for_attrs(&item.attrs),
194+
docs: self.docs_for_attrs(attrs),
194195
sig: sig::foreign_item_signature(item, self),
195-
attributes: lower_attributes(item.attrs.to_vec(), self),
196+
attributes: lower_attributes(attrs.to_vec(), self),
196197
}))
197198
}
198199
// FIXME(plietar): needs a new DefKind in rls-data

0 commit comments

Comments
 (0)