Skip to content

gccrs: Implement compilation support for TuplePatternItems::RANGED #3863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 2, 2025

Conversation

Polygonalr
Copy link
Contributor

This is part of implementing support for RestPatterns, RestPattern support for slices will be next.

Includes a fix to my little oopsie made in my type-checking code, and test updates to ensure that the mistake will not repeat.

Copy link
Member

@philberty philberty left a comment

Choose a reason for hiding this comment

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

Looks great but just minor comment on the test case and we need to see what the gimple is being generated here would help the review.

@Polygonalr Polygonalr force-pushed the restpattern-tuple-compile branch from e5d7765 to 3bb39a7 Compare July 1, 2025 15:05
gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-pattern.cc (visit(TuplePattern)): Fix
		incorrect logic for field size checking.

gcc/testsuite/ChangeLog:

	* rust/compile/tuple_mismatch.rs: Include RestPattern in test.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
Example GIMPLE output of the match statement for match-restpattern-tuple-1.rs:

...
RUSTTMP.2 = x;
_1 = RUSTTMP.2.__0;
_2 = _1 == 1;
_3 = RUSTTMP.2.__3;
_4 = _3 == 4;
_5 = _2 & _4;
if (_5 != 0) goto <D.109>; else goto <D.110>;
<D.109>:
{
    {

    }
    goto <D.104>;
}
<D.110>:
if (1 != 0) goto <D.111>; else goto <D.112>;
<D.111>:
{
    {

    }
    goto <D.104>;
}
<D.112>:
<D.104>:
...

gcc/rust/ChangeLog:

	* backend/rust-compile-pattern.cc (CompilePatternCheckExpr::visit(TuplePattern)):
		Implement check expression compilation for TuplePatternItems::RANGED.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
@Polygonalr Polygonalr force-pushed the restpattern-tuple-compile branch from 95a09d7 to 83fc41d Compare July 2, 2025 15:37
Copy link
Member

@philberty philberty left a comment

Choose a reason for hiding this comment

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

LGTM

@philberty philberty added this pull request to the merge queue Jul 2, 2025
Merged via the queue into Rust-GCC:master with commit 9b9273a Jul 2, 2025
13 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in libcore 1.49 Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants