gccrs icon indicating copy to clipboard operation
gccrs copied to clipboard

ast: Check before visiting a while-let's label

Open CohenArthur opened this issue 7 months ago • 1 comments

gcc/rust/ChangeLog:

* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Check that the WhileLet has a label
before visiting it.

gcc/testsuite/ChangeLog:

* rust/compile/while_let_without_label.rs: New test.

CohenArthur avatar May 19 '25 13:05 CohenArthur

Looks like we're missing binding context handling for the while let patterns -- speaking of, are they supposed to have multiple patterns, or should they just store a pattern which could be an AltPattern?

https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-pattern-loops

powerboat9 avatar May 19 '25 20:05 powerboat9

Looks like we're missing binding context handling for the while let patterns -- speaking of, are they supposed to have multiple patterns, or should they just store a pattern which could be an AltPattern?

https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-pattern-loops

I added a commit to handle while-let loops in NR2.0 in this PR, since we don't have the exclude file anymore - but I can split it in two PRs if you'd like @powerboat9.

regarding the vector of patterns vs alt-pattern - I'm not sure. this is how it's done in the base loop expression, but I think it could be changed to just one optional pattern (as loop loops don't have them)

CohenArthur avatar Jul 04 '25 13:07 CohenArthur