Skip to content

Conversation

@Harishankar14
Copy link
Contributor

This patch fixes two Internal Compiler Errors (ICEs) encountered during compilation.

First, it resolves a crash in CompilePatternLet::visit where the backend panicked upon encountering an error_mark node within a tuple pattern. A check was added to handle erroneous types gracefully.

Second, it fixes a crash in the MarkLive lint pass. Previously, visiting a TypeAlias could trigger rust_unreachable() if the AST-to-HIR mapping lookup failed. This assertion has been removed to allow the compiler to continue execution when the mapping is missing.

Fixes #4161

gcc/rust/ChangeLog:

* backend/rust-compile-pattern.cc (CompilePatternLet::visit): Check for error_mark_node before processing tuple patterns.
* checks/lints/rust-lint-marklive.cc (MarkLive::visit): Remove rust_unreachable() assertion to prevent ICE on missing mappings.

gcc/testsuite/ChangeLog:

* rust/compile/issue-4161.rs: New test.

Thank you for making Rust GCC better!

If your PR fixes an issue, you can add "Fixes #issue_number" into this
PR description and the git commit message. This way the issue will be
automatically closed when your PR is merged. If your change addresses
an issue but does not fully fix it please mark it as "Addresses #issue_number"
in the git commit message.

Here is a checklist to help you with your PR.

Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.

*Please write a comment explaining your change. This is the message
that will be part of the merge commit.

@Harishankar14 Harishankar14 changed the title gccrs: Fix ICEs in CompilePatternLet and MarkLive liveness analysis gccrs: fix(type-check): Resolve 'exceptional' error_mark in visit pattern compilation Jan 13, 2026
Copy link
Member

@P-E-P P-E-P left a comment

Choose a reason for hiding this comment

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

I'm not 100% confident because I'm not too familiar with that part of the codebase but it feels like you're trying here to fix the symptoms rather than the source of the problem.

@Harishankar14 Harishankar14 force-pushed the fix_segfault branch 2 times, most recently from 816cbd4 to 23add0c Compare January 17, 2026 08:57
The compiler was throwing an ICE when a Type Alias was used as a value
in a LetStmt (e.g., `let () = ::X = ();`). This occurred because the
backend pattern compiler received an `error_mark_node` for the
initialization expression and failed to handle it.

This patch adds a check in `CompileStmt` to detect if the initialization
expression is an `error_mark_node`. To prevent regression failures in
other tests (excess errors), this check is restricted specifically to
`TuplePattern`, which was the source of the crash. If detected, we now
emit a proper error message and exit early.

Fixes Rust-GCC#4161
gcc/rust/ChangeLog:

	* backend/rust-compile-stmt.cc (CompileStmt::visit): Check for
	error_mark_node in init expression for TuplePatterns and exit
	early if found.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4161.rs: New test.

Signed-off-by: Harishankar P P <[email protected]>
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.

tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in visit, at rust/backend/rust-compile-pattern.cc:1255

2 participants