1
Fork 0

Check attributes on struct expression fields.

Attributes on struct expression fields were not being checked for
validity. This adds the fields as HIR nodes so that `CheckAttrVisitor`
can visit those nodes to check their attributes.
This commit is contained in:
Eric Huss 2022-05-03 13:23:03 -07:00
parent 1b464c73b7
commit b651c1cebe
10 changed files with 47 additions and 18 deletions

View file

@ -653,7 +653,8 @@ impl CheckAttrVisitor<'_> {
| Target::ForeignTy
| Target::GenericParam(..)
| Target::MacroDef
| Target::PatField => None,
| Target::PatField
| Target::ExprField => None,
} {
tcx.sess.emit_err(errors::DocAliasBadLocation { span, attr_str, location });
return false;
@ -2064,6 +2065,11 @@ impl<'tcx> Visitor<'tcx> for CheckAttrVisitor<'tcx> {
};
self.check_attributes(expr.hir_id, expr.span, target, None);
if let hir::ExprKind::Struct(_, fields, _) = expr.kind {
for field in fields {
self.check_attributes(field.hir_id, field.span, Target::PatField, None);
}
}
intravisit::walk_expr(self, expr)
}