Skip to content

gccrs: Fix ICE on enum struct-variant patterns - #4817

Open
u7k4rs6 wants to merge 1 commit into
Rust-GCC:masterfrom
u7k4rs6:fix-4739-enum-struct-variant-refutable
Open

gccrs: Fix ICE on enum struct-variant patterns#4817
u7k4rs6 wants to merge 1 commit into
Rust-GCC:masterfrom
u7k4rs6:fix-4739-enum-struct-variant-refutable

Conversation

@u7k4rs6

@u7k4rs6 u7k4rs6 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #4739

StructPattern::is_refutable asserted that the ADT was not an enum, so struct patterns naming enum variants hit the assert. Return true for multi-variant enums and continue with the existing field checks for single-variant enums.

make check-rust passes cleanly with no unexpected failures.

This is independent of #4808. It changes a different function in the same file and the two changes do not overlap.

StructPattern::is_refutable asserted that the ADT was not an enum, so
struct patterns naming enum variants hit the assert. Return true for
multi-variant enums and continue with the existing field checks for
single-variant enums.

Fixes Rust-GCC#4739

gcc/rust/ChangeLog:

	* hir/tree/rust-hir-pattern-abstract.cc
	(StructPattern::is_refutable): Handle enum patterns with multiple
	variants.

gcc/testsuite/ChangeLog:

	* rust/compile/irrefutable-struct-variant.rs: New test.
	* rust/compile/refutable-struct.rs: Add regression tests for enum
	variant patterns in function parameters and let bindings.

Signed-off-by: Utkarsh Bahuguna <utkarshbahuguna10@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE in is_refutable, at rust/hir/tree/rust-hir-pattern-abstract.cc:287

1 participant