Skip to content

gccrs: add double negations lint#4643

Open
lucasly-ba wants to merge 1 commit into
Rust-GCC:masterfrom
lucasly-ba:double-negations
Open

gccrs: add double negations lint#4643
lucasly-ba wants to merge 1 commit into
Rust-GCC:masterfrom
lucasly-ba:double-negations

Conversation

@lucasly-ba

Copy link
Copy Markdown
Contributor

This patch adds the double negations lint, which warns on a double arithmetic negation such as - -x (Rust has no -- operator, so this is likely a mistake).

gcc/testsuite/ChangeLog:

* rust/compile/double-negations_0.rs: New test.

@lucasly-ba
lucasly-ba force-pushed the double-negations branch 3 times, most recently from 5b97f68 to 440ed39 Compare July 6, 2026 12:02
@lucasly-ba
lucasly-ba force-pushed the double-negations branch 3 times, most recently from 35d31c9 to 8734ccf Compare July 9, 2026 13:35
@lucasly-ba

Copy link
Copy Markdown
Contributor Author

@P-E-P

Warn on a double arithmetic negation such as `- -x`, which is likely a
mistake (Rust has no `--` operator).

gcc/rust/ChangeLog:

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

gcc/testsuite/ChangeLog:

	* rust/compile/double-negations_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 should be good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants