collect_structs: Also visit the type of array expression

Prevent compilation error in the generated code when dealing with
empty array expression of a given type, which is otherwise optimized out

Fixes #1733
This commit is contained in:
Olivier Goffart 2022-10-19 12:13:50 +02:00 committed by Olivier Goffart
parent 9899a3bd43
commit 328cee7289
2 changed files with 15 additions and 4 deletions

View file

@ -43,10 +43,10 @@ fn collect_structs_in_component(root_component: &Rc<Component>, hash: &mut BTree
});
visit_all_expressions(root_component, |expr, _| {
expr.visit_recursive(&mut |expr| {
if let Expression::Struct { ty, .. } = expr {
maybe_collect_object(ty)
}
expr.visit_recursive(&mut |expr| match expr {
Expression::Struct { ty, .. } => maybe_collect_object(ty),
Expression::Array { element_ty, .. } => maybe_collect_object(element_ty),
_ => (),
})
});
}