Fixes "for loop over an Option" warnings (#6291)

Was seeing these warnings when running `cargo check --all`:

```
warning: for loop over an `Option`. This is more readably written as an `if let` statement
    --> node/core/approval-voting/src/lib.rs:1147:21
     |
1147 |             for activated in update.activated {
     |                              ^^^^^^^^^^^^^^^^
     |
     = note: `#[warn(for_loops_over_fallibles)]` on by default
help: to check pattern in a loop use `while let`
     |
1147 |             while let Some(activated) = update.activated {
     |             ~~~~~~~~~~~~~~~         ~~~
help: consider using `if let` to clear intent
     |
1147 |             if let Some(activated) = update.activated {
     |             ~~~~~~~~~~~~         ~~~
```

My guess is that `activated` used to be a SmallVec or similar, as is
`deactivated`. It was changed to an `Option`, the `for` still compiled (it's
technically correct, just weird), and the compiler didn't catch it until now.
This commit is contained in:
Marcin S
2022-11-15 09:58:26 -05:00
committed by GitHub
parent c606deb32d
commit d53513ff66
8 changed files with 8 additions and 8 deletions
@@ -1144,7 +1144,7 @@ async fn handle_from_overseer<Context>(
FromOrchestra::Signal(OverseerSignal::ActiveLeaves(update)) => {
let mut actions = Vec::new();
for activated in update.activated {
if let Some(activated) = update.activated {
let head = activated.hash;
match import::handle_new_head(ctx, state, db, head, &*last_finalized_height).await {
Err(e) => return Err(SubsystemError::with_origin("db", e)),