Skip to content

gccrs: add break with label and loop lint - #4640

Merged
philberty merged 1 commit into
Rust-GCC:masterfrom
lucasly-ba:break-with-label-and-loop
Aug 16, 2026
Merged

gccrs: add break with label and loop lint#4640
philberty merged 1 commit into
Rust-GCC:masterfrom
lucasly-ba:break-with-label-and-loop

Conversation

@lucasly-ba

Copy link
Copy Markdown
Contributor

This patch adds the break with label and loop lint, which warns on a labeled break whose value is a loop expression, as it is easy to confuse with an unlabeled break of a labeled value.

Note: this branch is based on #4638 (fix ICE on break with a label and a value); the first commit is that fix, without which the construct cannot be compiled. It can be rebased once #4638 lands.

gcc/testsuite/ChangeLog:

* rust/compile/break-with-label-and-loop_0.rs: New test.

@lucasly-ba
lucasly-ba force-pushed the break-with-label-and-loop branch 3 times, most recently from 7ea2f1b to 10fefb6 Compare July 6, 2026 12:02
@lucasly-ba
lucasly-ba force-pushed the break-with-label-and-loop branch 3 times, most recently from 72f6354 to 19e9288 Compare July 9, 2026 13:35
@lucasly-ba

Copy link
Copy Markdown
Contributor Author

@P-E-P

@philberty philberty left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@philberty

Copy link
Copy Markdown
Member

merge conflicts

Warn on a labeled `break` whose value is a loop expression, as it is
easy to confuse with an unlabeled `break` of a labeled value.

gcc/rust/ChangeLog:

	* checks/lints/unused/rust-unused-checker.cc (UnusedChecker::visit):
	New.
	* checks/lints/unused/rust-unused-checker.h (UnusedChecker::visit):
	New.
	* rust-lang.cc (grs_langhook_init_options_struct): Enable warn_unused.

gcc/testsuite/ChangeLog:

	* rust/compile/break-with-label-and-loop_0.rs: New test.

Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
@lucasly-ba
lucasly-ba force-pushed the break-with-label-and-loop branch from 19e9288 to 98dc027 Compare August 15, 2026 21:28
@lucasly-ba

Copy link
Copy Markdown
Contributor Author

should be good @philberty

@philberty
philberty enabled auto-merge August 15, 2026 21:47
@philberty
philberty disabled auto-merge August 15, 2026 21:47
@philberty
philberty enabled auto-merge August 15, 2026 21:47
@philberty
philberty added this pull request to the merge queue Aug 15, 2026
Merged via the queue into Rust-GCC:master with commit adf0573 Aug 16, 2026
12 of 13 checks passed
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.

2 participants