Skip to content

Conversation

@philberty
Copy link
Member

@philberty philberty commented Aug 31, 2025

We need to catch the error node for the array capacity and return early. Otherwise we try to const evaluate something thats just silly. Also when compiling array expressions we can simply reuse the array capacity expression we already have cons folded.

Fixes #3965
Fixes #3969

gcc/rust/ChangeLog:

* backend/rust-compile-context.h: add assertions for context peeks
* backend/rust-compile-expr.cc (CompileExpr::visit): check for valid loop context
(CompileExpr::array_copied_expr): just reuse array tyty capacity value
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): catch error

gcc/testsuite/ChangeLog:

* rust/compile/issue-3965-1.rs: New test.
* rust/compile/issue-3965-2.rs: New test.

We need to catch the error node for the array capacity and return early.
Otherwise we try to const evaluate something thats just silly. Also
when compiling array expressions we can simply reuse the array capacity
expression we already have cons folded.

Fixes #3965

gcc/rust/ChangeLog:

	* backend/rust-compile-context.h: add assertions for context peeks
	* backend/rust-compile-expr.cc (CompileExpr::visit): check for valid loop context
	(CompileExpr::array_copied_expr): just reuse array tyty capacity value
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): catch error

gcc/testsuite/ChangeLog:

	* rust/compile/issue-3965-1.rs: New test.
	* rust/compile/issue-3965-2.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
We need to add a guard to catch the case when there is no loop context
for break outside of loop.

Fixes #3969

gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc (CompileExpr::visit): add guard

gcc/testsuite/ChangeLog:

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

Signed-off-by: Philip Herron <[email protected]>
@philberty philberty enabled auto-merge August 31, 2025 22:38
@philberty philberty added this pull request to the merge queue Aug 31, 2025
Merged via the queue into master with commit 45567f9 Aug 31, 2025
12 of 13 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in libcore 1.49 Aug 31, 2025
@philberty philberty deleted the phil/never-seg branch September 12, 2025 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

segfault in peek_loop_context segfault with [(); { continue }];

2 participants