Skip to content

gccrs: add while true lint - #4622

Open
lucasly-ba wants to merge 1 commit into
Rust-GCC:masterfrom
lucasly-ba:while-true
Open

gccrs: add while true lint#4622
lucasly-ba wants to merge 1 commit into
Rust-GCC:masterfrom
lucasly-ba:while-true

Conversation

@lucasly-ba

Copy link
Copy Markdown
Contributor

This patch adds the while true lint, which warns when a while loop uses the literal true as its condition and suggests using loop instead.

gcc/testsuite/ChangeLog:

* rust/compile/while-true_0.rs: New test.

@lucasly-ba
lucasly-ba force-pushed the while-true branch 2 times, most recently from 983b784 to 4a8f0b3 Compare June 29, 2026 22:18

@CohenArthur CohenArthur 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.

the implementation LGTM but just check the flag, I don't know that we want these warnings to be disabled if someone passes -Wno-unused-variable

Comment thread gcc/rust/checks/lints/unused/rust-unused-checker.cc Outdated
Comment thread gcc/rust/checks/lints/unused/rust-unused-checker.cc Outdated
Comment thread gcc/rust/checks/lints/unused/rust-unused-checker.cc Outdated
@lucasly-ba
lucasly-ba force-pushed the while-true branch 5 times, most recently from 4e04d65 to 97da3f2 Compare July 9, 2026 13:35
gcc/rust/ChangeLog:

	* checks/lints/unused/rust-unused-checker.cc (BoolLiteral): New.
	(ConstantTruth): New.
	(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/while-true_0.rs: New test.

Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
@lucasly-ba

Copy link
Copy Markdown
Contributor Author

@P-E-P

@lucasly-ba

Copy link
Copy Markdown
Contributor Author

Should be good @P-E-P @CohenArthur

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.

4 participants