Skip to content

gccrs: Fix bug when compiling const position intrinsic calls - #4856

Merged
philberty merged 1 commit into
masterfrom
phil/const-eval-tycheck
Sep 7, 2026
Merged

gccrs: Fix bug when compiling const position intrinsic calls#4856
philberty merged 1 commit into
masterfrom
phil/const-eval-tycheck

Conversation

@philberty

Copy link
Copy Markdown
Member

Since the changes to improve query_type to resolve function signitures seperate to the bodies we can end up with the case where we resolve just to a signiture which needs to call another function which is not yet type checked so when we do const-eval during typechecking it fails because its not ready.

This patch adds a new const context stack so we can override that behaviour for const eval to make sure we dont have unresolved chunks for this case.

Fixes #4855

gcc/rust/ChangeLog:

* checks/errors/privacy/rust-reachability.cc: dont need to assert
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): push const ctx
* typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItem::visit): likewise
* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): likewise
* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): likewse
* typecheck/rust-hir-type-check.h: likewise
* typecheck/rust-type-util.cc (query_type): check const_context_p

gcc/testsuite/ChangeLog:

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

Since the changes to improve query_type to resolve function signitures
seperate to the bodies we can end up with the case where we resolve just
to a signiture which needs to call another function which is not yet type
checked so when we do const-eval during typechecking it fails because its
not ready.

This patch adds a new const context stack so we can override that behaviour
for const eval to make sure we dont have unresolved chunks for this case.

Fixes #4855

gcc/rust/ChangeLog:

	* checks/errors/privacy/rust-reachability.cc: dont need to assert
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): push const ctx
	* typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItem::visit): likewise
	* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): likewise
	* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): likewse
	* typecheck/rust-hir-type-check.h: likewise
	* typecheck/rust-type-util.cc (query_type): check const_context_p

gcc/testsuite/ChangeLog:

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

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
@philberty philberty added the core Issue related to the compilation of the `core` crate label Sep 7, 2026
@philberty
philberty added this pull request to the merge queue Sep 7, 2026
Merged via the queue into master with commit 937d1fd Sep 7, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issue related to the compilation of the `core` crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

issue with const position call expr

1 participant