Skip to content

gccrs: Allow block expression with break - #5123

Open
sriramster wants to merge 1 commit into
Rust-GCC:masterfrom
sriramster:support_break_w_block
Open

sriramster wants to merge 1 commit into
Rust-GCC:masterfrom
sriramster:support_break_w_block

Conversation

@sriramster

@sriramster sriramster commented Nov 25, 2026 •

Copy link
Copy Markdown

Rust allows a block expression after a break statement, for example break {}. The parse_break_expr marked this expression as optional and stopped at {. Adding support for the same. This is similar to the PR#5114 which allows block expression after return statement.

Fixes #5129

gcc/rust/ChangeLog:

* parse/rust-parse.h (Parser::parser_break_expr) Add restrictions parameter
* parse/rust-parse-impl-expr.hxx (Parser::parse_break_expr): Parse a block expression after unless disallowed by caller.

gcc/testsuite/ChangeLog:

* rust/compile/break3.rs: New test for break with block.

Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.

@philberty

Copy link
Copy Markdown
Member

lgtm but you need to fix the git commit format

@sriramster
sriramster force-pushed the support_break_w_block branch 3 times, most recently from afb4bff to c4ed8a2 Compare November 27, 2026 07:30
Rust allows a block expression after a break statement, for example
`break {}`. The parse_break_expr marked this expression as optional
and stopped at `{`. Adding support for the same. This is similar to the
PR#5114 which allows block expression after `return` statement.

 Fixes Rust-GCC#5129

gcc/rust/ChangeLog:

	* parse/rust-parse.h (Parser::parser_break_expr) Add
	restrictions parameter
	* parse/rust-parse-impl-expr.hxx (Parser::parse_break_expr):
	Parse a block expression after unless disallowed by caller.

gcc/testsuite/ChangeLog:

	* rust/compile/break3.rs: New test for break with block.

Signed-off-by: Sriram Raghunathan <sriram@hcoop.net>
@sriramster
sriramster force-pushed the support_break_w_block branch from c4ed8a2 to 4585ae2 Compare November 27, 2026 07:32

This branch has not been deployed

No deployments
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.

Missnig syntax for break expr

2 participants