Skip to content

Commit

Permalink
fixed new clippy warnings (#1449)
Browse files Browse the repository at this point in the history
  • Loading branch information
LesnyRumcajs authored Mar 1, 2022
1 parent 6f49203 commit 6fc9ea1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion blockchain/chain/src/store/chain_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ where
/// be passed through the VM.
pub fn messages_for_tipset(&self, ts: &Tipset) -> Result<Vec<ChainMessage>, Error> {
let bmsgs = self.block_msgs_for_tipset(ts)?;
Ok(bmsgs.into_iter().map(|bm| bm.messages).flatten().collect())
Ok(bmsgs.into_iter().flat_map(|bm| bm.messages).collect())
}

/// get miner state given address and tipsetkeys
Expand Down
2 changes: 1 addition & 1 deletion forest/src/cli/wallet_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl WalletCommands {
});
}
Self::SetDefault { key } => {
let key_parse_result = Address::from_str(&key.to_string());
let key_parse_result = Address::from_str(key);

if key_parse_result.is_err() {
cli_error_and_die("Error parsing address. Verify that the address exists and is in the keystore", 1);
Expand Down
8 changes: 4 additions & 4 deletions ipld/amt/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ where
match self {
Node::Link { links } => {
// Check if first index is a link and all other values are empty.
links.get(0).map(|l| l.as_ref()).flatten().is_some()
links.get(0).and_then(|l| l.as_ref()).is_some()
&& links
.get(1..)
.map(|l| l.iter().all(|l| l.is_none()))
Expand Down Expand Up @@ -244,8 +244,8 @@ where
let sub_i = i / nodes_for_height(bit_width, height);

match self {
Node::Leaf { vals, .. } => Ok(vals.get(i).map(|v| v.as_ref()).flatten()),
Node::Link { links, .. } => match links.get(sub_i).map(|v| v.as_ref()).flatten() {
Node::Leaf { vals, .. } => Ok(vals.get(i).and_then(|v| v.as_ref())),
Node::Link { links, .. } => match links.get(sub_i).and_then(|v| v.as_ref()) {
Some(Link::Cid { cid, cache }) => {
let cached_node = cache.get_or_try_init(|| {
bs.get::<CollapsedNode<V>>(cid)?
Expand Down Expand Up @@ -353,7 +353,7 @@ where
let sub_i = i / nodes_for_height(bit_width, height);

match self {
Self::Leaf { vals } => Ok(vals.get_mut(i).map(std::mem::take).flatten()),
Self::Leaf { vals } => Ok(vals.get_mut(i).and_then(std::mem::take)),
Self::Link { links } => {
let (deleted, replace) = match &mut links[sub_i] {
Some(Link::Dirty(n)) => {
Expand Down
6 changes: 3 additions & 3 deletions key_management/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl Wallet {

/// Return the Address of the default KeyInfo in the Wallet
pub fn get_default(&self) -> Result<Address, Error> {
let key_info = self.keystore.get(&"default".to_string())?;
let key_info = self.keystore.get("default")?;
let k = Key::try_from(key_info)?;
Ok(k.address)
}
Expand All @@ -133,7 +133,7 @@ impl Wallet {
let addr = format!("wallet-{}", key.address);
self.keystore.put(addr, key.key_info.clone())?;
self.keys.insert(key.address, key.clone());
let value = self.keystore.get(&"default".to_string());
let value = self.keystore.get("default");
if value.is_err() {
self.keystore
.put("default".to_string(), key.key_info.clone())
Expand All @@ -151,7 +151,7 @@ impl Wallet {

/// Return the default Address for KeyStore
pub fn get_default(keystore: &KeyStore) -> Result<Address, Error> {
let key_info = keystore.get(&"default".to_string())?;
let key_info = keystore.get("default")?;
let k = Key::try_from(key_info)?;
Ok(k.address)
}
Expand Down
6 changes: 3 additions & 3 deletions node/rpc-api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn map_lotus_type(lotus_param: &str) -> String {
param.push('>');
}

param = param.replace("*", "");
param = param.replace('*', "");
param = param.replace("TipSet", "Tipset");

// Strip namespaces
Expand Down Expand Up @@ -118,11 +118,11 @@ fn map_lotus_type(lotus_param: &str) -> String {
fn compare_types(lotus: &str, forest: &str) -> bool {
let lotus = lotus.replace("Json", "");
let lotus = lotus.replace("Option<", "");
let lotus = lotus.replace(">", "");
let lotus = lotus.replace('>', "");

let forest = forest.replace("Json", "");
let forest = forest.replace("Option<", "");
let forest = forest.replace(">", "");
let forest = forest.replace('>', "");

lotus.trim_end_matches("Json") != forest.trim_end_matches("Json")
}
Expand Down
2 changes: 1 addition & 1 deletion node/rpc/src/wallet_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ where

let addr = format!("wallet-{}", key.address);
keystore.put(addr, key.key_info.clone())?;
let value = keystore.get(&"default".to_string());
let value = keystore.get("default");
if value.is_err() {
keystore.put("default".to_string(), key.key_info)?
}
Expand Down

0 comments on commit 6fc9ea1

Please sign in to comment.