Remove hir::StructField::attrs.

This commit is contained in:
Camille GILLOT 2020-11-27 00:27:34 +01:00
parent 3c0afc3e1c
commit c298744da7
5 changed files with 8 additions and 7 deletions

View File

@ -802,6 +802,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
self.lower_ty(&f.ty, ImplTraitContext::disallowed())
};
let hir_id = self.lower_node_id(f.id);
self.lower_attrs(hir_id, &f.attrs);
hir::StructField {
span: f.span,
hir_id,
@ -812,7 +813,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
},
vis: self.lower_visibility(&f.vis, None),
ty,
attrs: self.lower_attrs(hir_id, &f.attrs),
}
}

View File

@ -2631,7 +2631,6 @@ pub struct StructField<'hir> {
pub vis: Visibility<'hir>,
pub hir_id: HirId,
pub ty: &'hir Ty<'hir>,
pub attrs: &'hir [Attribute],
}
impl StructField<'_> {

View File

@ -888,7 +888,7 @@ impl<'a> State<'a> {
self.popen();
self.commasep(Inconsistent, struct_def.fields(), |s, field| {
s.maybe_print_comment(field.span.lo());
s.print_outer_attributes(&field.attrs);
s.print_outer_attributes(s.attrs(field.hir_id));
s.print_visibility(&field.vis);
s.print_type(&field.ty)
});
@ -910,7 +910,7 @@ impl<'a> State<'a> {
for field in struct_def.fields() {
self.hardbreak_if_not_bol();
self.maybe_print_comment(field.span.lo());
self.print_outer_attributes(&field.attrs);
self.print_outer_attributes(self.attrs(field.hir_id));
self.print_visibility(&field.vis);
self.print_ident(field.ident);
self.word_nbsp(":");

View File

@ -387,6 +387,7 @@ impl<'tcx> SaveContext<'tcx> {
let id = id_from_def_id(field_def_id);
let span = self.span_from_span(field.ident.span);
let attrs = self.tcx.hir().attrs(field.hir_id);
Some(Def {
kind: DefKind::Field,
@ -398,9 +399,9 @@ impl<'tcx> SaveContext<'tcx> {
parent: Some(id_from_def_id(scope_def_id)),
children: vec![],
decl_id: None,
docs: self.docs_for_attrs(&field.attrs),
docs: self.docs_for_attrs(attrs),
sig: sig::field_signature(field, self),
attributes: lower_attributes(field.attrs.to_vec(), self),
attributes: lower_attributes(attrs.to_vec(), self),
})
}

View File

@ -187,7 +187,8 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
fn check_struct_field(&mut self, cx: &LateContext<'tcx>, sf: &'tcx hir::StructField<'_>) {
if !sf.is_positional() {
self.check_missing_docs_attrs(cx, &sf.attrs, sf.span, "a", "struct field");
let attrs = cx.tcx.hir().attrs(sf.hir_id);
self.check_missing_docs_attrs(cx, attrs, sf.span, "a", "struct field");
}
}