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:
parent
1b464c73b7
commit
b651c1cebe
10 changed files with 47 additions and 18 deletions
|
@ -1406,8 +1406,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
}
|
||||
|
||||
fn lower_expr_field(&mut self, f: &ExprField) -> hir::ExprField<'hir> {
|
||||
let hir_id = self.lower_node_id(f.id);
|
||||
self.lower_attrs(hir_id, &f.attrs);
|
||||
hir::ExprField {
|
||||
hir_id: self.next_id(),
|
||||
hir_id,
|
||||
ident: self.lower_ident(f.ident),
|
||||
expr: self.lower_expr(&f.expr),
|
||||
span: self.lower_span(f.span),
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue