Skip to content

solana-ibc: fix build warnings #90

solana-ibc: fix build warnings

solana-ibc: fix build warnings #90

Triggered via pull request October 10, 2023 18:41
@mina86mina86
opened #17
mpn/d
Status Failure
Total duration 9m 31s
Artifacts

master.yml

on: pull_request
Fit to window
Zoom out
Zoom in

Annotations

19 errors and 1 warning
Rust nightly
Process completed with exit code 101.
Rust stable
Process completed with exit code 101.
the `Err`-variant returned from this function is very large: solana/solana-ibc/programs/solana-ibc/src/lib.rs#L30
error: the `Err`-variant returned from this function is very large --> solana/solana-ibc/programs/solana-ibc/src/lib.rs:30:10 | 30 | ) -> Result<()> { | ^^^^^^^^^^ the `Err`-variant is at least 160 bytes | = help: try reducing the size of `anchor_lang::error::Error`, for example by boxing large elements or replacing it with `Box<anchor_lang::error::Error>` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err = note: `-D clippy::result-large-err` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::result_large_err)]`
this expression creates a reference which is immediately dereferenced by the compiler: solana/solana-ibc/programs/solana-ibc/src/validation_context.rs#L367
error: this expression creates a reference which is immediately dereferenced by the compiler --> solana/solana-ibc/programs/solana-ibc/src/validation_context.rs:367:9 | 367 | &self | ^^^^^ help: change this to: `self` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `-D clippy::needless-borrow` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::needless_borrow)]`
unnecessary use of `to_string`: solana/solana-ibc/programs/solana-ibc/src/validation_context.rs#L358
error: unnecessary use of `to_string` --> solana/solana-ibc/programs/solana-ibc/src/validation_context.rs:358:32 | 358 | match Pubkey::from_str(&signer.to_string()) { | ^^^^^^^^^^^^^^^^^^^ help: use: `signer.as_ref()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned = note: `-D clippy::unnecessary-to-owned` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::unnecessary_to_owned)]`
useless use of `format!`: solana/solana-ibc/programs/solana-ibc/src/validation_context.rs#L104
error: useless use of `format!` --> solana/solana-ibc/programs/solana-ibc/src/validation_context.rs:104:26 | 104 | description: format!( | __________________________^ 105 | | "The `host_consensus_state` is not supported on Solana \ 106 | | protocol." 107 | | ), | |_____________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format = note: `-D clippy::useless-format` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::useless_format)]` help: consider using `.to_string()` | 104 ~ description: "The `host_consensus_state` is not supported on Solana \ 105 ~ protocol.".to_string(), |
redundant closure: solana/solana-ibc/programs/solana-ibc/src/validation_context.rs#L87
error: redundant closure --> solana/solana-ibc/programs/solana-ibc/src/validation_context.rs:87:22 | 87 | .map_err(|e| ContextError::ClientError(e))?) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `ContextError::ClientError` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure = note: `-D clippy::redundant-closure` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::redundant_closure)]`
question mark operator is useless here: solana/solana-ibc/programs/solana-ibc/src/validation_context.rs#L86
error: question mark operator is useless here --> solana/solana-ibc/programs/solana-ibc/src/validation_context.rs:86:9 | 86 | / Ok(ibc::Height::new(self.height.0, self.height.1) 87 | | .map_err(|e| ContextError::ClientError(e))?) | |________________________________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_question_mark = note: `-D clippy::needless-question-mark` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::needless_question_mark)]` help: try removing question mark and `Ok()` | 86 ~ ibc::Height::new(self.height.0, self.height.1) 87 + .map_err(|e| ContextError::ClientError(e)) |
called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`: solana/solana-ibc/programs/solana-ibc/src/execution_context.rs#L397
error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` --> solana/solana-ibc/programs/solana-ibc/src/execution_context.rs:397:5 | 397 | // hash_map.get_mut(&key).map(|sequences| { 398 | || sequences.push(u64::from(*sequence)); 399 | || }); | ||______^- help: try: `if let Some(sequences) = hash_map.get_mut(&key) { sequences.push(u64::from(*sequence)); }` | |______| | | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unit_fn
called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`: solana/solana-ibc/programs/solana-ibc/src/execution_context.rs#L370
error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` --> solana/solana-ibc/programs/solana-ibc/src/execution_context.rs:370:13 | 370 | / self.ibc_events_history 371 | | .get_mut(&inner_host_height) 372 | | .map(|events| events.push(event_in_bytes.clone())); | |__________________________________________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unit_fn help: try | 370 ~ if let Some(events) = self.ibc_events_history 371 + .get_mut(&inner_host_height) { events.push(event_in_bytes.clone()) } |
usage of `contains_key` followed by `insert` on a `BTreeMap`: solana/solana-ibc/programs/solana-ibc/src/execution_context.rs#L369
error: usage of `contains_key` followed by `insert` on a `BTreeMap` --> solana/solana-ibc/programs/solana-ibc/src/execution_context.rs:369:9 | 369 | / if self.ibc_events_history.contains_key(&inner_host_height) { 370 | | self.ibc_events_history 371 | | .get_mut(&inner_host_height) 372 | | .map(|events| events.push(event_in_bytes.clone())); ... | 375 | | .insert(inner_host_height, vec![event_in_bytes.clone()]); 376 | | } | |_________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_entry = note: `-D clippy::map-entry` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::map_entry)]` help: try | 369 ~ if let std::collections::btree_map::Entry::Vacant(e) = self.ibc_events_history.entry(inner_host_height) { 370 + e.insert(vec![event_in_bytes.clone()]); 371 + } else { 372 + self.ibc_events_history 373 + .get_mut(&inner_host_height) 374 + .map(|events| events.push(event_in_bytes.clone())); 375 + } |
called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`: solana/solana-ibc/programs/solana-ibc/src/execution_context.rs#L279
error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` --> solana/solana-ibc/programs/solana-ibc/src/execution_context.rs:279:9 | 279 | / self.packet_acknowledgement_sequence_sets 280 | | .get_mut(&( 281 | | ack_path.port_id.clone().to_string(), 282 | | ack_path.channel_id.clone().to_string(), ... | 286 | | sequences.remove(sequence_as_u64 as usize); 287 | | }); | |______________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unit_fn help: try | 279 ~ if let Some(sequences) = self.packet_acknowledgement_sequence_sets 280 + .get_mut(&( 281 + ack_path.port_id.clone().to_string(), 282 + ack_path.channel_id.clone().to_string(), 283 + )) { ... } |
called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`: solana/solana-ibc/programs/solana-ibc/src/execution_context.rs#L221
error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` --> solana/solana-ibc/programs/solana-ibc/src/execution_context.rs:221:9 | 221 | / self.packet_commitment_sequence_sets 222 | | .get_mut(&( 223 | | commitment_path.port_id.clone().to_string(), 224 | | commitment_path.channel_id.clone().to_string(), ... | 231 | | sequences.remove(index); 232 | | }); | |______________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unit_fn = note: `-D clippy::option-map-unit-fn` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::option_map_unit_fn)]` help: try | 221 ~ if let Some(sequences) = self.packet_commitment_sequence_sets 222 + .get_mut(&( 223 + commitment_path.port_id.clone().to_string(), 224 + commitment_path.channel_id.clone().to_string(), 225 + )) { ... } |
using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`: solana/solana-ibc/programs/solana-ibc/src/execution_context.rs#L138
error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)` --> solana/solana-ibc/programs/solana-ibc/src/execution_context.rs:138:9 | 138 | / self.client_processed_heights.get_mut(&client_id.to_string()).and_then( 139 | | |processed_heights| { 140 | | Some(BTreeMap::insert( 141 | | processed_heights, ... | 148 | | }, 149 | | ); | |_________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bind_instead_of_map help: try | 138 ~ self.client_processed_heights.get_mut(&client_id.to_string()).map(|processed_heights| BTreeMap::insert( 139 + processed_heights, 140 + (height.revision_number(), height.revision_height()), 141 + ( 142 + host_height.revision_number(), 143 + host_height.revision_height(), 144 + ), 145 ~ )); |
using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`: solana/solana-ibc/programs/solana-ibc/src/execution_context.rs#L103
error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)` --> solana/solana-ibc/programs/solana-ibc/src/execution_context.rs:103:9 | 103 | / self.client_processed_times.get_mut(&client_id.to_string()).and_then( 104 | | |processed_times| { 105 | | Some(BTreeMap::insert( 106 | | processed_times, ... | 110 | | }, 111 | | ); | |_________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bind_instead_of_map = note: `-D clippy::bind-instead-of-map` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::bind_instead_of_map)]` help: try | 103 ~ self.client_processed_times.get_mut(&client_id.to_string()).map(|processed_times| BTreeMap::insert( 104 + processed_times, 105 + (height.revision_number(), height.revision_height()), 106 + timestamp.nanoseconds(), 107 ~ )); |
casting integer literal to `u64` is unnecessary: solana/solana-ibc/programs/solana-ibc/src/client_state.rs#L307
error: casting integer literal to `u64` is unnecessary --> solana/solana-ibc/programs/solana-ibc/src/client_state.rs:307:53 | 307 | let end_height = (height.revision_number(), 1 as u64); | ^^^^^^^^ help: try: `1_u64` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
casting integer literal to `u64` is unnecessary: solana/solana-ibc/programs/solana-ibc/src/client_state.rs#L289
error: casting integer literal to `u64` is unnecessary --> solana/solana-ibc/programs/solana-ibc/src/client_state.rs:289:57 | 289 | let end_height = (height.revision_number() + 1, 1 as u64); | ^^^^^^^^ help: try: `1_u64` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast = note: `-D clippy::unnecessary-cast` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::unnecessary_cast)]`
constants have by default a `'static` lifetime: solana/solana-ibc/programs/solana-ibc/src/lib.rs#L9
error: constants have by default a `'static` lifetime --> solana/solana-ibc/programs/solana-ibc/src/lib.rs:9:33 | 9 | const SOLANA_IBC_STORAGE_SEED: &'static [u8] = b"solana_ibc_storage"; | -^^^^^^^----- help: consider removing `'static`: `&[u8]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes = note: `-D clippy::redundant-static-lifetimes` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::redundant_static_lifetimes)]`
Miscellaneous checks
Clippy had exited with the 101 exit code
Miscellaneous checks
The following actions uses node12 which is deprecated and will be forced to run on node16: actions-rs/clippy-check@v1. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/