Skip to content

Conversation

Polygonalr
Copy link
Contributor

Implements let statement binding support for identifier patterns' subpatterns, together with closure param bindings as well (albeit untested because of #4071)

…terns

Trimmed GIMPLE code gen for let-identifierpattern-subpattern.rs

...
      RUSTTMP.1.__0 = 0;
      RUSTTMP.1.__1 = 2;
      RUSTTMP.1.__2 = 3;
      bar = RUSTTMP.1.__0;
      RUSTTMP.2 = RUSTTMP.1.__1;
      RUSTTMP.3 = RUSTTMP.1.__2;
      foo.__0 = 0;
      foo.__1 = 2;
      foo.__2 = 3;
      ret = 1;
      RUSTTMP.5 = foo;
      _1 = RUSTTMP.5.__0;
      _2 = _1 == 0;
      _3 = RUSTTMP.5.__1;
      _4 = _3 == 2;
      _5 = _2 & _4;
      _6 = RUSTTMP.5.__2;
      _7 = _6 == 3;
      _8 = _5 & _7;
      if (_8 != 0) goto <D.143>; else goto <D.144>;
      <D.143>:
      {
        {
          ret = bar;
        }
        goto <D.137>;
      }
...

gcc/rust/ChangeLog:

	* backend/rust-compile-pattern.cc(CompilePatternLet::visit(IdentifierPattern)):
	Add support for subpatterns.
	* backend/rust-compile-var-decl.h(CompileVarDecl::visit(IdentifierPattern)):
	Implement compilation for subpatterns.

Signed-off-by: Yap Zhi Heng <[email protected]>
gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-pattern.cc(ClosureParamInfer(IdentifierPattern)):
	Resolve subpattern types for IdentifierPattern.

Signed-off-by: Yap Zhi Heng <[email protected]>
@Polygonalr Polygonalr force-pushed the identifier-pattern-sub-decl branch from e16ace6 to fc9502d Compare August 12, 2025 14:14
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 Aug 17, 2025
Merged via the queue into Rust-GCC:master with commit 165d7c6 Aug 17, 2025
13 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in libcore 1.49 Aug 17, 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