gccrs: add path statement lint - #4623
Closed
lucasly-ba wants to merge 1 commit into
Closed
lucasly-ba wants to merge 1 commit into
lucasly-ba wants to merge 1 commit into
Conversation
lucasly-ba
force-pushed
the
path-statements
branch
2 times, most recently
from
June 29, 2026 21:35
1d07cc0 to
b43acd6
Compare
CohenArthur
approved these changes
Jun 30, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Jun 30, 2026
lucasly-ba
force-pushed
the
path-statements
branch
4 times, most recently
from
July 8, 2026 23:41
0a0f62b to
38c8c64
Compare
Collaborator
|
Does this catch cases where a path statement is used, and has an effect? Say, mod a {
pub(crate) const B: bool = true;
}
pub fn foo_is_active () -> bool {
a::B
} |
lucasly-ba
force-pushed
the
path-statements
branch
3 times, most recently
from
July 9, 2026 18:38
d3a0712 to
7c84bc3
Compare
Contributor
Author
Yes. The lint only fires on a path in statement position, a path used as a tail/return expression like your a::B isn't an ExprStmt, so it's never flagged same as rustc's path_statements. I've added your example as a test to make that explicit. |
Contributor
Author
Member
|
merge conflicts but other wise looks good |
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_value. gcc/testsuite/ChangeLog: * rust/compile/path-statements_0.rs: New test. Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
lucasly-ba
force-pushed
the
path-statements
branch
from
August 15, 2026 21:27
7c84bc3 to
abe7508
Compare
Contributor
Author
|
should be good @philberty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch adds the path statement lint, which warns on a statement made of a single path expression, as it has no effect.
gcc/testsuite/ChangeLog: