Skip to content

Conversation

@vishruth-thimmaiah
Copy link
Contributor

@vishruth-thimmaiah vishruth-thimmaiah commented Oct 29, 2025

When a const generic with a default value is not trailing, emit an error.

Closes #4220

Godbolt: https://godbolt.org/z/exzMx7aKx

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_generic_params): Emit an error when const generics with a default value is not trailing.

gcc/testsuite/ChangeLog:

* rust/compile/const_generics_17.rs: New test.
* rust/compile/generics14.rs: New test.

Thank you for making Rust GCC better!

If your PR fixes an issue, you can add "Fixes #issue_number" into this
PR description and the git commit message. This way the issue will be
automatically closed when your PR is merged. If your change addresses
an issue but does not fully fix it please mark it as "Addresses #issue_number"
in the git commit message.

Here is a checklist to help you with your PR.

Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.

*Please write a comment explaining your change. This is the message
that will be part of the merge commit.

When a const generic with a default value is not trailing, emit an
error.

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_generic_params): Emit
	an error when const generics with a default value is not
	trailing.

gcc/testsuite/ChangeLog:

	* rust/compile/const_generics_17.rs: New test.
	* rust/compile/generics14.rs: New test.

Signed-off-by: vishruth-thimmaiah <vishruththimmaiah@gmail.com>
Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look great to me! I wonder if it wouldn't be easier to do that check after parsing is complete, but I think it is fine like this. Well done, thank you!

@CohenArthur CohenArthur added this pull request to the merge queue Oct 31, 2025
Merged via the queue into Rust-GCC:master with commit 09d92fc Oct 31, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE in get_mappings_from_generic_args, at rust/typecheck/rust-tyty-subst.cc:887

2 participants