Skip to content

lint: Fix ICE on error_mark_node in unused variable linter#4438

Merged
P-E-P merged 1 commit intoRust-GCC:masterfrom
Pasta-coder:issue-3910
Apr 13, 2026
Merged

lint: Fix ICE on error_mark_node in unused variable linter#4438
P-E-P merged 1 commit intoRust-GCC:masterfrom
Pasta-coder:issue-3910

Conversation

@Pasta-coder
Copy link
Copy Markdown
Contributor

Fixes #3910

Comment thread gcc/rust/checks/lints/rust-lint-unused-var.cc Outdated
@philberty
Copy link
Copy Markdown
Member

actually this is hiding a code gen bug it shouldnt merge this unless we understand why an error mark node has crept into the IR

@Pasta-coder
Copy link
Copy Markdown
Contributor Author

Because const generics aren't fully lowered yet, compile_constant_item returns an error_mark_node. However, the backend blindly pushes this into the context via ctx->insert_const_decl inside rust-compile-implitem.cc and rust-compile-item.cc without checking if the compilation actually succeeded.

I will instead add an if (const_expr != error_mark_node) guard right before the insert_const_decl calls in the backend. I'll update the PR with this fix shortly!

@Pasta-coder Pasta-coder force-pushed the issue-3910 branch 2 times, most recently from 91167e1 to 532c867 Compare February 16, 2026 09:47
Copy link
Copy Markdown
Member

@philberty philberty left a comment

Choose a reason for hiding this comment

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

LGTM

@Pasta-coder
Copy link
Copy Markdown
Contributor Author

@P-E-P can we merge this ?

Comment thread gcc/testsuite/rust/compile/issue-3910.rs Outdated
Fixes Rust-GCC#3910

gcc/rust/ChangeLog:

	* backend/rust-compile-item.cc (CompileItem::visit): Do not insert
	const_expr into the context if it is an error_mark_node.
	* backend/rust-compile-implitem.cc (CompileTraitItem::visit): Likewise.

gcc/testsuite/ChangeLog:

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

Signed-off-by: jayant chauhan <0001jayant@gmail.com>
@Pasta-coder
Copy link
Copy Markdown
Contributor Author

cc @P-E-P

@P-E-P P-E-P added this pull request to the merge queue Apr 13, 2026
Merged via the queue into Rust-GCC:master with commit f1e56c4 Apr 13, 2026
12 checks passed
@Pasta-coder Pasta-coder deleted the issue-3910 branch April 13, 2026 22:18
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 check_decl, at rust/checks/lints/rust-lint-unused-var.cc:28

4 participants