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

examples: fix clippy's complaints about redundant_locals #823

Merged
merged 1 commit into from
Oct 6, 2023

Conversation

piodul
Copy link
Collaborator

@piodul piodul commented Oct 6, 2023

Rust 1.73 got released very recently and introduced a new version of clippy, with new lints. The parallel and parallel-prepared examples contain code which redefines a local variable:

for i in 0..100_000usize {
    // ...
    tokio::task::spawn(async move {
        let i = i;
        // ...
    });
}

This is completely unnecesary and can be removed, as per clippy's suggestion:

error: redundant redefinition of a binding
  --> examples/parallel-prepared.rs:36:9
   |
36 |     for i in 0..100_000usize {
   |         ^
...
44 |             let i = i;
   |             ^^^^^^^^^^
   |
   = help: remove the redefinition of `i`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_locals
   = note: `#[deny(clippy::redundant_locals)]` on by default

Pre-review checklist

  • I have split my patch into logically separate commits.
  • All commit messages clearly explain what they change and why.
  • I added relevant tests for new features and bug fixes.
  • All commits compile, pass static checks and pass test.
  • PR description sums up the changes and reasons why they should be introduced.
  • I have provided docstrings for the public items that I want to introduce.
  • I have adjusted the documentation in ./docs/source/.
  • I added appropriate Fixes: annotations to PR description.

Rust 1.73 got released very recently and introduced a new version of
clippy, with new lints. The `parallel` and `parallel-prepared` examples
contain code which redefines a local variable:

```
for i in 0..100_000usize {
    // ...
    tokio::task::spawn(async move {
        let i = i;
        // ...
    });
}
```

This is completely unnecesary and can be removed, as per clippy's
suggestion:

```
error: redundant redefinition of a binding
  --> examples/parallel-prepared.rs:36:9
   |
36 |     for i in 0..100_000usize {
   |         ^
...
44 |             let i = i;
   |             ^^^^^^^^^^
   |
   = help: remove the redefinition of `i`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_locals
   = note: `#[deny(clippy::redundant_locals)]` on by default
```
@piodul piodul requested a review from Lorak-mmk October 6, 2023 08:08
@piodul piodul merged commit 17652b2 into scylladb:main Oct 6, 2023
8 checks passed
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.

2 participants