Skip to content

gccrs: Fix handling where clauses into two passes - #4875

Merged
philberty merged 1 commit into
masterfrom
phil/resolve-item
Sep 8, 2026
Merged

gccrs: Fix handling where clauses into two passes#4875
philberty merged 1 commit into
masterfrom
phil/resolve-item

Conversation

@philberty

Copy link
Copy Markdown
Member

Where constraints are annoying so we need to do it in two passes.

  1. Register bounds on the regular single segment TypePaths so like P: Deref
  2. Then register regular type bindings like I::Item or Item = U::Item

As they can be order dependant as the initial predicate needs added to then param decls then onto whatever projections after.

Fixes #4864

gcc/rust/ChangeLog:

* hir/tree/rust-hir-item.h: missing non const helper.
* typecheck/rust-hir-type-check-base.h: new defer_bindings.
* typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit): new helper
(TypeCheckImplItem::resolve_function_signature): Likewise.
(TypeCheckImplItem::visit): Likewise.
* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit):  Likewise.
(TypeCheckItem::resolve_function_signature):  Likewise.
(TypeCheckItem::resolve_impl_block_substitutions):  Likewise.
* typecheck/rust-hir-type-check-type.cc (ResolveWhereClauseItem::Resolve): new helper
(ResolveWhereClauseItem::visit): support defer.
* typecheck/rust-hir-type-check-type.h: update header.
* typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): call new helper
* typecheck/rust-tyty-bounds.cc: defer flag

gcc/testsuite/ChangeLog:

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

Where constraints are annoying so we need to do it in two passes.

 1. Register bounds on the regular single segment TypePaths so like P: Deref
 2. Then register regular type bindings like I::Item or Item = U::Item

As they can be order dependant as the initial predicate needs added to then
param decls then onto whatever projections after.

Fixes #4864

gcc/rust/ChangeLog:

	* hir/tree/rust-hir-item.h: missing non const helper.
	* typecheck/rust-hir-type-check-base.h: new defer_bindings.
	* typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit): new helper
	(TypeCheckImplItem::resolve_function_signature): Likewise.
	(TypeCheckImplItem::visit): Likewise.
	* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit):  Likewise.
	(TypeCheckItem::resolve_function_signature):  Likewise.
	(TypeCheckItem::resolve_impl_block_substitutions):  Likewise.
	* typecheck/rust-hir-type-check-type.cc (ResolveWhereClauseItem::Resolve): new helper
	(ResolveWhereClauseItem::visit): support defer.
	* typecheck/rust-hir-type-check-type.h: update header.
	* typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): call new helper
	* typecheck/rust-tyty-bounds.cc: defer flag

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4864.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 8, 2026
@philberty
philberty enabled auto-merge September 8, 2026 12:21
@philberty
philberty added this pull request to the merge queue Sep 8, 2026
Merged via the queue into master with commit 112b46e Sep 8, 2026
13 checks passed
@philberty
philberty deleted the phil/resolve-item branch September 10, 2026 16:12
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.

failed to resolve item

1 participant