gccrs: Implement compilation support for TuplePatternItems::RANGED#3863
Merged
Conversation
philberty
requested changes
Jul 1, 2025
philberty
left a comment
Member
There was a problem hiding this comment.
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.
e5d7765 to
3bb39a7
Compare
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>
95a09d7 to
83fc41d
Compare
Member
|
@Polygonalr FYI, no need to add extra indentation in the changelog: not |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.