]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: add unused mut lint
authorLucas Ly Ba <lucas.ly-ba@outlook.com>
Mon, 17 Nov 2025 16:13:33 +0000 (16:13 +0000)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 23 Dec 2025 11:16:49 +0000 (12:16 +0100)
commitfe65006e77a434872ffbae3c0343dff4e7c31013
tree8a8053fe3a188d432358224fc2bd8e0b18e5259d
parent2b7d71783018d0ed68d0760392094cd1b0e95c2b
gccrs: add unused mut lint

gcc/rust/ChangeLog:

* checks/lints/unused/rust-unused-checker.cc (UnusedChecker::UnusedChecker):
Add warning for identifier pattern and field ident pattern in struct
(UnusedChecker::visit): Add methods.
* checks/lints/unused/rust-unused-checker.h: Same here.
* checks/lints/unused/rust-unused-collector.cc (UnusedCollector::UnusedCollector):
Collect unused mut variables
(UnusedCollector::visit): Add methods.
* checks/lints/unused/rust-unused-collector.h: Same here.
* checks/lints/unused/rust-unused-context.cc (UnusedContext::remove_assign):
Add methods for unused mut set.
(UnusedContext::add_mut): Same here.
(UnusedContext::remove_mut): Same here.
(UnusedContext::is_mut_used): Same here.
* checks/lints/unused/rust-unused-context.h: Same here.

gcc/testsuite/ChangeLog:

* rust/compile/unused-mut-identifier_0.rs: New test.
* rust/compile/unused-mut-struct-field_0.rs: New test.

Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
gcc/rust/checks/lints/unused/rust-unused-checker.cc
gcc/rust/checks/lints/unused/rust-unused-checker.h
gcc/rust/checks/lints/unused/rust-unused-collector.cc
gcc/rust/checks/lints/unused/rust-unused-collector.h
gcc/rust/checks/lints/unused/rust-unused-context.cc
gcc/rust/checks/lints/unused/rust-unused-context.h
gcc/testsuite/rust/compile/unused-mut-identifier_0.rs [new file with mode: 0644]
gcc/testsuite/rust/compile/unused-mut-struct-field_0.rs [new file with mode: 0644]