Skip to content

Commit

Permalink
Prevent hir dump from visiting missing types
Browse files Browse the repository at this point in the history
The hir dump was trying to visit init expression and types even when
those were missing.

gcc/rust/ChangeLog:

	* hir/rust-hir-dump.cc (Dump::visit): Add check for type and initial
	expression.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
  • Loading branch information
P-E-P committed Dec 10, 2024
1 parent 898f2e8 commit 4c4a569
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gcc/rust/hir/rust-hir-dump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2254,8 +2254,10 @@ Dump::visit (LetStmt &e)

put_field ("variable_pattern", e.get_pattern ().as_string ());

visit_field ("type", e.get_type ());
visit_field ("init_expr", e.get_init_expr ());
if (e.has_type ())
visit_field ("type", e.get_type ());
if (e.has_init_expr ())
visit_field ("init_expr", e.get_init_expr ());

end ("LetStmt");
}
Expand Down

0 comments on commit 4c4a569

Please sign in to comment.