fix(stakes): add missing doc #106
clippy
11 errors
Details
Results
Message level | Amount |
---|---|
Internal compiler error | 0 |
Error | 11 |
Warning | 0 |
Note | 0 |
Help | 0 |
Versions
- rustc 1.79.0 (129f3b996 2024-06-10)
- cargo 1.79.0 (ffa9cf99a 2024-06-03)
- clippy 0.1.79 (129f3b9 2024-06-10)
Annotations
Check failure on line 996 in data_structures/src/staking/stakes.rs
github-actions / clippy
unnecessary map of the identity function
error: unnecessary map of the identity function
--> data_structures/src/staking/stakes.rs:995:21
|
995 | .take(4)
| _____________________^
996 | | .map(|sk| sk)
| |_________________________^ help: remove the call to `map`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_identity
= note: `-D clippy::map-identity` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::map_identity)]`
Check failure on line 438 in data_structures/src/staking/stakes.rs
github-actions / clippy
returning the result of a `let` binding from a block
error: returning the result of a `let` binding from a block
--> data_structures/src/staking/stakes.rs:438:9
|
427 | / let valid_staking_pair = if !self.by_validator.contains_key(&validator) {
428 | | Ok(())
429 | | } else {
430 | | let stake_key = StakeKey::from((validator.clone(), withdrawer));
... |
435 | | }
436 | | };
| |__________- unnecessary `let` binding
437 |
438 | valid_staking_pair
| ^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return
= note: `-D clippy::let-and-return` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::let_and_return)]`
help: return the expression directly
|
427 ~
428 |
429 ~ if !self.by_validator.contains_key(&validator) {
430 + Ok(())
431 + } else {
432 + let stake_key = StakeKey::from((validator.clone(), withdrawer));
433 + if self.by_key.contains_key(&stake_key) {
434 + Ok(())
435 + } else {
436 + Err(StakesError::DifferentWithdrawer { validator })
437 + }
438 + }
|
Check failure on line 359 in data_structures/src/staking/stakes.rs
github-actions / clippy
field assignment outside of initializer for an instance created with Default::default()
error: field assignment outside of initializer for an instance created with Default::default()
--> data_structures/src/staking/stakes.rs:359:9
|
359 | stakes.by_key = entries;
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
note: consider initializing the variable with `Stakes::<Address, Coins, Epoch, Power> { by_key: entries, ..Default::default() }` and removing relevant reassignments
--> data_structures/src/staking/stakes.rs:358:9
|
358 | let mut stakes = Stakes::default();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default
= note: `-D clippy::field-reassign-with-default` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::field_reassign_with_default)]`
Check failure on line 438 in data_structures/src/staking/stakes.rs
github-actions / clippy
returning the result of a `let` binding from a block
error: returning the result of a `let` binding from a block
--> data_structures/src/staking/stakes.rs:438:9
|
427 | / let valid_staking_pair = if !self.by_validator.contains_key(&validator) {
428 | | Ok(())
429 | | } else {
430 | | let stake_key = StakeKey::from((validator.clone(), withdrawer));
... |
435 | | }
436 | | };
| |__________- unnecessary `let` binding
437 |
438 | valid_staking_pair
| ^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return
= note: `-D clippy::let-and-return` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::let_and_return)]`
help: return the expression directly
|
427 ~
428 |
429 ~ if !self.by_validator.contains_key(&validator) {
430 + Ok(())
431 + } else {
432 + let stake_key = StakeKey::from((validator.clone(), withdrawer));
433 + if self.by_key.contains_key(&stake_key) {
434 + Ok(())
435 + } else {
436 + Err(StakesError::DifferentWithdrawer { validator })
437 + }
438 + }
|
Check failure on line 359 in data_structures/src/staking/stakes.rs
github-actions / clippy
field assignment outside of initializer for an instance created with Default::default()
error: field assignment outside of initializer for an instance created with Default::default()
--> data_structures/src/staking/stakes.rs:359:9
|
359 | stakes.by_key = entries;
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
note: consider initializing the variable with `Stakes::<Address, Coins, Epoch, Power> { by_key: entries, ..Default::default() }` and removing relevant reassignments
--> data_structures/src/staking/stakes.rs:358:9
|
358 | let mut stakes = Stakes::default();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default
= note: `-D clippy::field-reassign-with-default` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::field_reassign_with_default)]`
Check failure on line 4560 in data_structures/src/chain/mod.rs
github-actions / clippy
casting `u16` to `i64` may become silently lossy if you later change the type
error: casting `u16` to `i64` may become silently lossy if you later change the type
--> data_structures/src/chain/mod.rs:4560:19
|
4560 | / self.checkpoints_period as i64) as u32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i64::from(self.checkpoints_period)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless
= note: requested on the command line with `-D clippy::cast-lossless`
Check failure on line 4560 in data_structures/src/chain/mod.rs
github-actions / clippy
casting `i64` to `u32` may lose the sign of the value
error: casting `i64` to `u32` may lose the sign of the value
--> data_structures/src/chain/mod.rs:4558:33
|
4558 | let epochs_pre_v2 = ((self.checkpoint_zero_timestamp_v2
| _________________________________^
4559 | | - self.checkpoint_zero_timestamp)
4560 | | / self.checkpoints_period as i64) as u32;
| |________________________________________________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_sign_loss
= note: requested on the command line with `-D clippy::cast-sign-loss`
Check failure on line 4560 in data_structures/src/chain/mod.rs
github-actions / clippy
casting `i64` to `u32` may truncate the value
error: casting `i64` to `u32` may truncate the value
--> data_structures/src/chain/mod.rs:4558:33
|
4558 | let epochs_pre_v2 = ((self.checkpoint_zero_timestamp_v2
| _________________________________^
4559 | | - self.checkpoint_zero_timestamp)
4560 | | / self.checkpoints_period as i64) as u32;
| |________________________________________________________^
|
= help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_possible_truncation
= note: requested on the command line with `-D clippy::cast-possible-truncation`
help: ... or use `try_from` and handle the error accordingly
|
4558 ~ let epochs_pre_v2 = u32::try_from((self.checkpoint_zero_timestamp_v2
4559 ~ - self.checkpoint_zero_timestamp) / self.checkpoints_period as i64);
|
Check failure on line 4560 in data_structures/src/chain/mod.rs
github-actions / clippy
casting `u16` to `i64` may become silently lossy if you later change the type
error: casting `u16` to `i64` may become silently lossy if you later change the type
--> data_structures/src/chain/mod.rs:4560:19
|
4560 | / self.checkpoints_period as i64) as u32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i64::from(self.checkpoints_period)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless
= note: requested on the command line with `-D clippy::cast-lossless`
Check failure on line 4560 in data_structures/src/chain/mod.rs
github-actions / clippy
casting `i64` to `u32` may lose the sign of the value
error: casting `i64` to `u32` may lose the sign of the value
--> data_structures/src/chain/mod.rs:4558:33
|
4558 | let epochs_pre_v2 = ((self.checkpoint_zero_timestamp_v2
| _________________________________^
4559 | | - self.checkpoint_zero_timestamp)
4560 | | / self.checkpoints_period as i64) as u32;
| |________________________________________________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_sign_loss
= note: requested on the command line with `-D clippy::cast-sign-loss`
Check failure on line 4560 in data_structures/src/chain/mod.rs
github-actions / clippy
casting `i64` to `u32` may truncate the value
error: casting `i64` to `u32` may truncate the value
--> data_structures/src/chain/mod.rs:4558:33
|
4558 | let epochs_pre_v2 = ((self.checkpoint_zero_timestamp_v2
| _________________________________^
4559 | | - self.checkpoint_zero_timestamp)
4560 | | / self.checkpoints_period as i64) as u32;
| |________________________________________________________^
|
= help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_possible_truncation
= note: requested on the command line with `-D clippy::cast-possible-truncation`
help: ... or use `try_from` and handle the error accordingly
|
4558 ~ let epochs_pre_v2 = u32::try_from((self.checkpoint_zero_timestamp_v2
4559 ~ - self.checkpoint_zero_timestamp) / self.checkpoints_period as i64);
|