Skip to content

Commit 3c0afc3

Browse files
committed
Remove hir::Variant::attrs.
1 parent a0a4611 commit 3c0afc3

File tree

5 files changed

+10
-15
lines changed

5 files changed

+10
-15
lines changed

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,9 +749,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
749749

750750
fn lower_variant(&mut self, v: &Variant) -> hir::Variant<'hir> {
751751
let id = self.lower_node_id(v.id);
752+
self.lower_attrs(id, &v.attrs);
752753
hir::Variant {
753754
id,
754-
attrs: self.lower_attrs(id, &v.attrs),
755755
data: self.lower_variant_data(id, &v.data),
756756
disr_expr: v.disr_expr.as_ref().map(|e| self.lower_anon_const(e)),
757757
ident: v.ident,

compiler/rustc_hir/src/hir.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,8 +2538,6 @@ pub struct Variant<'hir> {
25382538
/// Name of the variant.
25392539
#[stable_hasher(project(name))]
25402540
pub ident: Ident,
2541-
/// Attributes of the variant.
2542-
pub attrs: &'hir [Attribute],
25432541
/// Id of the variant (not the constructor, see `VariantData::ctor_hir_id()`).
25442542
pub id: HirId,
25452543
/// Fields and constructor id of the variant.

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ impl<'a> State<'a> {
834834
for v in variants {
835835
self.space_if_not_bol();
836836
self.maybe_print_comment(v.span.lo());
837-
self.print_outer_attributes(&v.attrs);
837+
self.print_outer_attributes(self.attrs(v.id));
838838
self.ibox(INDENT_UNIT);
839839
self.print_variant(v);
840840
self.s.word(",");

compiler/rustc_save_analysis/src/dump_visitor.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ impl<'tcx> DumpVisitor<'tcx> {
554554
let span = self.span_from_span(name_span);
555555
let id = id_from_hir_id(variant.id, &self.save_ctxt);
556556
let parent = Some(id_from_def_id(item.def_id.to_def_id()));
557+
let attrs = self.tcx.hir().attrs(variant.id);
557558

558559
self.dumper.dump_def(
559560
&access,
@@ -567,12 +568,9 @@ impl<'tcx> DumpVisitor<'tcx> {
567568
parent,
568569
children: vec![],
569570
decl_id: None,
570-
docs: self.save_ctxt.docs_for_attrs(&variant.attrs),
571+
docs: self.save_ctxt.docs_for_attrs(attrs),
571572
sig: sig::variant_signature(variant, &self.save_ctxt),
572-
attributes: lower_attributes(
573-
variant.attrs.to_vec(),
574-
&self.save_ctxt,
575-
),
573+
attributes: lower_attributes(attrs.to_vec(), &self.save_ctxt),
576574
},
577575
);
578576
}
@@ -594,6 +592,7 @@ impl<'tcx> DumpVisitor<'tcx> {
594592
let span = self.span_from_span(name_span);
595593
let id = id_from_hir_id(variant.id, &self.save_ctxt);
596594
let parent = Some(id_from_def_id(item.def_id.to_def_id()));
595+
let attrs = self.tcx.hir().attrs(variant.id);
597596

598597
self.dumper.dump_def(
599598
&access,
@@ -607,12 +606,9 @@ impl<'tcx> DumpVisitor<'tcx> {
607606
parent,
608607
children: vec![],
609608
decl_id: None,
610-
docs: self.save_ctxt.docs_for_attrs(&variant.attrs),
609+
docs: self.save_ctxt.docs_for_attrs(attrs),
611610
sig: sig::variant_signature(variant, &self.save_ctxt),
612-
attributes: lower_attributes(
613-
variant.attrs.to_vec(),
614-
&self.save_ctxt,
615-
),
611+
attributes: lower_attributes(attrs.to_vec(), &self.save_ctxt),
616612
},
617613
);
618614
}

src/tools/clippy/clippy_lints/src/missing_doc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
192192
}
193193

194194
fn check_variant(&mut self, cx: &LateContext<'tcx>, v: &'tcx hir::Variant<'_>) {
195-
self.check_missing_docs_attrs(cx, &v.attrs, v.span, "a", "variant");
195+
let attrs = cx.tcx.hir().attrs(v.id);
196+
self.check_missing_docs_attrs(cx, attrs, v.span, "a", "variant");
196197
}
197198
}

0 commit comments

Comments
 (0)