Make Node::ExprField a child of Node::Expr.
This was incorrectly inserting the ExprField as a sibling of the struct expression. This required adjusting various parts which were looking at parent node of a field expression to find the struct.
This commit is contained in:
parent
dcd5177fd4
commit
7b36047239
5 changed files with 139 additions and 148 deletions
|
@ -226,17 +226,19 @@ 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);
|
||||
});
|
||||
}
|
||||
|
||||
fn visit_expr_field(&mut self, field: &'hir ExprField<'hir>) {
|
||||
self.insert(field.span, field.hir_id, Node::ExprField(field));
|
||||
self.with_parent(field.hir_id, |this| {
|
||||
intravisit::walk_expr_field(this, field);
|
||||
});
|
||||
}
|
||||
|
||||
fn visit_stmt(&mut self, stmt: &'hir Stmt<'hir>) {
|
||||
self.insert(stmt.span, stmt.hir_id, Node::Stmt(stmt));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue