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

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.

@CohenArthur CohenArthur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! nit but if you want in your changelog you can move the (StructPattern::is_refutable): Handle enum patterns with multiple variants. line above so it fills out more of the previous line

@u7k4rs6
u7k4rs6 force-pushed the fix-4739-enum-struct-variant-refutable branch from 987539a to 7d57d75 Compare September 19, 2026 18:34
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>
@u7k4rs6
u7k4rs6 force-pushed the fix-4739-enum-struct-variant-refutable branch from 7d57d75 to e4e901a Compare September 19, 2026 18:35
@u7k4rs6
u7k4rs6 requested a review from CohenArthur September 29, 2026 18:49

This branch has not been deployed

No deployments
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

2 participants