Skip to content

gccrs: check for invalid const calls during code-gen#3852

Merged
philberty merged 1 commit into
masterfrom
phil/dev
Jun 23, 2025
Merged

gccrs: check for invalid const calls during code-gen#3852
philberty merged 1 commit into
masterfrom
phil/dev

Conversation

@philberty

Copy link
Copy Markdown
Member

Closure calls are not const so this is invalid. This patch fixes two bugs

  1. Make the look at the parent context optional for generics
  2. Ensure we look for non const calls during call expr code-gen

Fixes #3551

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::visit): add const call check
* backend/rust-compile-item.cc (CompileItem::visit): ensure we upfront compile types where possible
* backend/rust-compile-item.h: update header
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): make parent ctx optional

gcc/testsuite/ChangeLog:

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

Closure calls are not const so this is invalid. This patch fixes two bugs

  1. Make the look at the parent context optional for generics
  2. Ensure we look for non const calls during call expr code-gen

Fixes #3551

gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc (CompileExpr::visit): add const call check
	* backend/rust-compile-item.cc (CompileItem::visit): ensure we upfront compile types where
	possible
	* backend/rust-compile-item.h: update header
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): make parent ctx optional

gcc/testsuite/ChangeLog:

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

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
@philberty philberty added this pull request to the merge queue Jun 23, 2025
Merged via the queue into master with commit 1f1fefe Jun 23, 2025
12 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in libcore 1.49 Jun 23, 2025
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.

ICE in peek_context, at rust/typecheck/rust-typecheck-context.cc:169

1 participant