Skip to content

gccrs: Fix parser handling for Foo<Bar: SomeTrait> - #4843

Merged
philberty merged 1 commit into
masterfrom
phil/generic-args
Sep 3, 2026
Merged

gccrs: Fix parser handling for Foo<Bar: SomeTrait>#4843
philberty merged 1 commit into
masterfrom
phil/generic-args

Conversation

@philberty

@philberty philberty commented Sep 3, 2026

Copy link
Copy Markdown
Member

The parser only recognized Foo<Bar = T> for the generic type bindings syntax. This parses both flavours now into update generic args type.

Fixes #1726

gcc/rust/ChangeLog:

* ast/rust-path.cc (GenericArgsBinding::as_string): new format
* ast/rust-path.h (struct GenericArgsBinding): new kinds for bindings
* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_binding): new
* hir/tree/rust-hir-path.cc (GenericArgsBinding::GenericArgsBinding): likewise
(GenericArgsBinding::operator=): likewise
* hir/tree/rust-hir-path.h (class GenericArgsBinding): likewise
* hir/tree/rust-hir.cc (GenericArgsBinding::to_string): likewise
* parse/rust-parse-impl.hxx: peek for both types
* typecheck/rust-type-util.cc (normalize_projection): track constrains
* typecheck/rust-tyty-bounds.cc (TypeBoundPredicate::TypeBoundPredicate): new ctor
(TypeBoundPredicate::operator=): likewise
* typecheck/rust-tyty-subst.cc (SubstitutionArgumentMappings::get_constraint_args): new
* typecheck/rust-tyty-subst.h: new
* typecheck/rust-unify.cc (UnifyRules::expect_projection): fix loop

gcc/testsuite/ChangeLog:

* rust/compile/associated-type-bound.rs: New test.
* rust/compile/issue-1726-1.rs: New test.
* rust/compile/issue-1726-2.rs: New test.

@philberty philberty added the core Issue related to the compilation of the `core` crate label Sep 3, 2026
The parser only recognized Foo<Bar = T> for the generic type bindings
syntax. This parses both flavours now into update generic args type.

Fixes #1726

gcc/rust/ChangeLog:

	* ast/rust-path.cc (GenericArgsBinding::as_string): new format
	* ast/rust-path.h (struct GenericArgsBinding): new kinds for bindings
	* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_binding): new
	* hir/tree/rust-hir-path.cc (GenericArgsBinding::GenericArgsBinding): likewise
	(GenericArgsBinding::operator=): likewise
	* hir/tree/rust-hir-path.h (class GenericArgsBinding): likewise
	* hir/tree/rust-hir.cc (GenericArgsBinding::to_string): likewise
	* parse/rust-parse-impl.hxx: peek for both types
	* typecheck/rust-type-util.cc (normalize_projection): track constrains
	* typecheck/rust-tyty-bounds.cc (TypeBoundPredicate::TypeBoundPredicate): new ctor
	(TypeBoundPredicate::operator=): likewise
	* typecheck/rust-tyty-subst.cc (SubstitutionArgumentMappings::get_constraint_args): new
	* typecheck/rust-tyty-subst.h: new
	* typecheck/rust-unify.cc (UnifyRules::expect_projection): fix loop

gcc/testsuite/ChangeLog:

	* rust/compile/associated-type-bound.rs: New test.
	* rust/compile/issue-1726-1.rs: New test.
	* rust/compile/issue-1726-2.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
@philberty
philberty added this pull request to the merge queue Sep 3, 2026
Merged via the queue into master with commit f3d7821 Sep 3, 2026
13 checks passed
@philberty
philberty deleted the phil/generic-args branch September 4, 2026 19:59
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.

Generic argument handling with Associated type bounds

2 participants