rust: Fix ICE in function_set_parameters#4501
Conversation
When lowering a function to HIR with a refutable pattern in its parameter pattern, we were ICE'ing due to a lack of checks for invalid refutable patterns. Fix this by erroring on invalid patterns while lowering a function. Fixes Rust-GCC#3919 gcc/rust/ChangeLog: * hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): added refutable pattern checks for function params. gcc/testsuite/ChangeLog: * rust/compile/issue-3919-ice-func-parms.rs: New test. Signed-off-by: Egas Ribeiro <egas.g.ribeiro@tecnico.ulisboa.pt>
CohenArthur
left a comment
There was a problem hiding this comment.
Thank you, that's good work! I'm not sure that we'll keep that check here in the lowerer but it definitely improves the compiler for now, so I'm in favor of merging it :)
I wasn't sure where to place it more naturally before the lowering phase, but i felt it would be an improvement anyway. // Pattern base HIR node
class Pattern : public Node, virtual public FullVisitable
{
...
// possible virtual methods: is_refutable()
...
}doing that would replace this fix with an equivalent solution calling |
When lowering a function to HIR with a refutable pattern in its parameter pattern, we were ICE'ing due to a lack of checks for invalid refutable patterns. Fix this by erroring on invalid patterns while lowering a function.
Fixes #3919
gcc/rust/ChangeLog:
gcc/testsuite/ChangeLog: