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

clippy: unnecessary_map_or #4392

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brooksprumo
Copy link

@brooksprumo brooksprumo commented Jan 10, 2025

Problem

New clippy lints when upgrading to rust 1.84.0.

warning: this `map_or` is redundant
   --> sdk/program/src/vote/state/mod.rs:702:12
    |
702 |           if self
    |  ____________^
703 | |             .last_voted_slot()
704 | |             .map_or(false, |last_voted_slot| next_vote_slot <= last_voted_slot)
    | |_______________________________________________________________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or
    = note: `#[warn(clippy::unnecessary_map_or)]` on by default
help: use is_some_and instead
    |
702 ~         if self
703 +             .last_voted_slot().is_some_and(|last_voted_slot| next_vote_slot <= last_voted_slot)

Summary of Changes

Resolve the lints by using the suggestions from clippy and checking the code.

Partially fixes #4380

Copy link

mergify bot commented Jan 10, 2025

The Firedancer team maintains a line-for-line reimplementation of the
native programs, and until native programs are moved to BPF, those
implementations must exactly match their Agave counterparts.
If this PR represents a change to a native program implementation (not
tests), please include a reviewer from the Firedancer team. And please
keep refactors to a minimum.

@brooksprumo brooksprumo force-pushed the rust-1.84.0/clippy/unnecessary-map-or branch from 71dc294 to 3cb2ba7 Compare January 10, 2025 16:09
Comment on lines -79 to -81
if maybe_last_leader
.map_or(true, |last_leader| last_leader != leader_pubkey)
{
Copy link
Author

Choose a reason for hiding this comment

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

This one is a tiny bit different:

warning: this `map_or` is redundant
  --> core/src/warm_quic_cache_service.rs:79:28
   |
79 |                           if maybe_last_leader
   |  ____________________________^
80 | |                             .map_or(true, |last_leader| last_leader != leader_pubkey)
   | |_____________________________________________________________________________________^ help: use a standard comparison instead: `(maybe_last_leader != Some(leader_pubkey))`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or
   = note: `#[warn(clippy::unnecessary_map_or)]` on by default

@brooksprumo brooksprumo marked this pull request as ready for review January 10, 2025 16:15
@brooksprumo brooksprumo added the automerge automerge Merge this Pull Request automatically once CI passes label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge automerge Merge this Pull Request automatically once CI passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New clippy lints in Rust 1.84.0
1 participant