Skip to content

Conversation

lucasly-ba
Copy link

@lucasly-ba lucasly-ba commented Oct 13, 2025

Adds a proper check for missing patterns in while expressions.

Fixes #4162

gcc/rust/ChangeLog:

    * parse/rust-parse-impl.h(Parser<ManagedTokenSource>::parse_while_let_loop_expr):
    Add check for missing pattern.

gcc/testsuite/ChangeLog:
* rust/compile/issue-4162.rs: New test.

Signed-off-by: Lucas Ly Ba [email protected]

@dkm
Copy link
Member

dkm commented Oct 13, 2025

In the changelog, please correctly designate the item being modified (Parser<ManagedTokenSource>::parse_while_let_loop_expr) between ( ). You'll see plenty of examples in the history of the project :)

@lucasly-ba lucasly-ba force-pushed the 4162 branch 6 times, most recently from 1370931 to 083af83 Compare October 14, 2025 09:30
Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

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

Thank you, good work!

= parse_match_arm_patterns (EQUAL);
// TODO: have to ensure that there is at least 1 pattern?
// ensure that there is at least 1 pattern
if (!predicate_patterns.size ())
Copy link
Member

Choose a reason for hiding this comment

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

I think this is clearer:

Suggested change
if (!predicate_patterns.size ())
if (predicate_patterns.empty())

Adds a proper check for missing patterns in while expressions.

Fixes Rust-GCC#4162

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h(Parser<ManagedTokenSource>::parse_while_let_loop_expr):
	Add check for missing pattern.

gcc/testsuite/ChangeLog:
	* rust/compile/issue-4162.rs: New test.

Signed-off-by: Lucas Ly Ba <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE in desugar, at rust/ast/rust-desugar-while-let.cc:56 `while let = 5 {}

3 participants