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

@@ -224,6 +224,11 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
fn visit_expr(&mut self, expr: &'hir Expr<'hir>) {
self.insert(expr.span, expr.hir_id, Node::Expr(expr));
if let ExprKind::Struct(_, fields, _) = expr.kind {
for field in fields {
self.insert(field.span, field.hir_id, Node::ExprField(field));
}
}
self.with_parent(expr.hir_id, |this| {
intravisit::walk_expr(this, expr);