Skip to content

gccrs: Fix ICE when constant is missing and expression#3834

Merged
philberty merged 1 commit into
masterfrom
phil/const-bug
Jun 19, 2025
Merged

gccrs: Fix ICE when constant is missing and expression#3834
philberty merged 1 commit into
masterfrom
phil/const-bug

Conversation

@philberty

Copy link
Copy Markdown
Member

This is an invalid test case and doesnt work with rustc, we dont fully pick up the errors. Nr2 does handle this and puts out an extra good diagnostic but the old NR doesnt so for now i added this to the exclude list and then when we remove old name resolver this issue goes away.

Fixes #3642

gcc/rust/ChangeLog:

* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): check for has_expr
* hir/rust-hir-dump.cc (Dump::visit): likewise
* hir/tree/rust-hir-item.h: add has_expr helper
* resolve/rust-ast-resolve-item.cc (ResolveItem::visit): check for has_expr
* resolve/rust-ast-resolve-stmt.h: likewise
* typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): likewise

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: nr2 puts out an extra error
* rust/compile/issue-3642.rs: New test.

This is an invalid test case and doesnt work with rustc, we dont fully pick
up the errors. Nr2 does handle this and puts out an extra good diagnostic
but the old NR doesnt so for now i added this to the exclude list and then
when we remove old name resolver this issue goes away.

Fixes #3642

gcc/rust/ChangeLog:

	* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): check for has_expr
	* hir/rust-hir-dump.cc (Dump::visit): likewise
	* hir/tree/rust-hir-item.h: add has_expr helper
	* resolve/rust-ast-resolve-item.cc (ResolveItem::visit): check for has_expr
	* resolve/rust-ast-resolve-stmt.h: likewise
	* typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): likewise

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: nr2 puts out an extra error
	* rust/compile/issue-3642.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
@philberty philberty self-assigned this Jun 18, 2025
@philberty philberty added the bug label Jun 18, 2025
@philberty philberty added this pull request to the merge queue Jun 19, 2025
Merged via the queue into master with commit 98e07b3 Jun 19, 2025
12 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in libcore 1.49 Jun 19, 2025
@philberty philberty deleted the phil/const-bug branch June 21, 2025 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

ICE: in get_expr, at rust/ast/rust-item.h:2538

1 participant