Skip to content

Commit

Permalink
examples: fix clippy's complaints about redundant_locals
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
piodul committed Oct 6, 2023
1 parent 14ec2d2 commit 64575b8
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 2 deletions.
1 change: 0 additions & 1 deletion examples/parallel-prepared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ async fn main() -> Result<()> {
let prepared = prepared.clone();
let permit = sem.clone().acquire_owned().await;
tokio::task::spawn(async move {
let i = i;
session
.execute(&prepared, (i as i32, 2 * i as i32))
.await
Expand Down
1 change: 0 additions & 1 deletion examples/parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ async fn main() -> Result<()> {
let session = session.clone();
let permit = sem.clone().acquire_owned().await;
tokio::task::spawn(async move {
let i = i;
session
.query(
format!(
Expand Down

0 comments on commit 64575b8

Please sign in to comment.