Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust: Unused variable follow-up work #17744

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions rust/ql/test/query-tests/unusedentities/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ fn arrays() {

println!("lets use {:?}", js);

for k // SPURIOUS: unused variable [macros not yet supported]
for k
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that the comment is no longer there, it might be nicer to remove the linebreak before in (in all three cases)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't like the idea of changing formatting around just because query results change. If it was correct to split the for loop into two lines before (so that any results on k or ks are clearer), it's still justified now IMO.

I'm admittedly not an unbiased source as changing this would require me to fix up a couple of other commits I have ready. If you don't agree with my justification, say so and I'll make the change after all my work on this is merged.

in ks
{
println!("lets use {}", k); // [unreachable FALSE POSITIVE]
Expand Down Expand Up @@ -166,12 +166,12 @@ fn loops() {

for _ in 1..10 {}

for x // SPURIOUS: unused variable [macros not yet supported]
for x
in 1..10 {
println!("x is {}", x);
}

for x // SPURIOUS: unused variable [macros not yet supported]
for x
in 1..10 {
assert!(x != 11);
}
Expand Down
Loading