Skip to content

Conversation

Polygonalr
Copy link
Contributor

@Polygonalr Polygonalr commented Aug 27, 2025

Fixes #3930

Also optimized the code for the NO_REST case and implemented the missing HAS_REST case for the read-only checker while I'm at it, since the read-only checker's test does not compile without #3930's fix.

GIMPLE dump from compiling issue-3930.rs:

...
  const i32 b;
  const i32 a;

  D.114.__0 = 2;
  D.114.__1 = 3;
  RUSTTMP.1 = D.114;
  a = RUSTTMP.1.__0;
  b = RUSTTMP.1.__1;
...

gcc/rust/ChangeLog:

	* backend/rust-compile-var-decl.h (CompileVarDecl::visit(TuplePattern)): Implement
	variable declaration bindings for tuple patterns with rest pattern (i.e.
	TuplePatternItemsHasRest).

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
gcc/rust/ChangeLog:

	* checks/errors/rust-readonly-check.cc (collect_assignment_tuple): Implement
	read-only checker for tuple patterns with rest pattern.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
@Polygonalr Polygonalr changed the title Implement missing variable declaration binding case for TuplePatternItemsHasRest Implement missing var decl binding & read-only checker cases for TuplePatternItemsHasRest Aug 28, 2025
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 31, 2025
Merged via the queue into Rust-GCC:master with commit e7bafde Aug 31, 2025
13 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in libcore 1.49 Aug 31, 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.

ICE in visit, at rust/backend/rust-compile-pattern.cc:846 let (a, .., b) = (2, 3)
2 participants