Skip to content

Commit

Permalink
Fix new Clippy warnings introduced in Rust 1.65 (#2813)
Browse files Browse the repository at this point in the history
  • Loading branch information
romac authored Nov 3, 2022
1 parent 3de97d5 commit 1c0d935
Show file tree
Hide file tree
Showing 45 changed files with 355 additions and 359 deletions.
6 changes: 3 additions & 3 deletions crates/relayer-cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ mod git {

// Returns the short hash of the last git commit
pub fn last_commit_hash(&self) -> String {
let commit = Self::command(&["rev-parse", "--short", "HEAD"]);
let commit = Self::command(["rev-parse", "--short", "HEAD"]);
String::from_utf8_lossy(&commit.stdout).into_owned()
}

// Checks if the git repo is dirty
pub fn is_dirty(&self) -> bool {
!Self::command(&["diff-index", "--quiet", "HEAD", "--"])
!Self::command(["diff-index", "--quiet", "HEAD", "--"])
.status
.success()
}
Expand All @@ -73,7 +73,7 @@ mod git {
// returns true iff git is installed and current directory is a git repo
fn is_git_repo() -> bool {
Command::new("git")
.args(&["rev-parse", "--git-dir"])
.args(["rev-parse", "--git-dir"])
.output()
.map_or(false, |o| o.status.success())
}
Expand Down
6 changes: 3 additions & 3 deletions crates/relayer-cli/src/chain_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ use tokio::task::{JoinError, JoinHandle};

/// Generate packet filters from Vec<IBCPath> and load them in a Map(chain_name -> filter).
fn construct_packet_filters(ibc_paths: Vec<IBCPath>) -> HashMap<String, PacketFilter> {
let mut packet_filters = HashMap::new();
let mut packet_filters: HashMap<_, Vec<_>> = HashMap::new();

for path in ibc_paths {
for channel in path.channels {
let chain_1 = path.chain_1.chain_name.to_owned();
let chain_2 = path.chain_2.chain_name.to_owned();

let filters_1 = packet_filters.entry(chain_1).or_insert(Vec::new());
let filters_1 = packet_filters.entry(chain_1).or_default();

filters_1.push((
FilterPattern::Exact(channel.chain_1.port_id.clone()),
FilterPattern::Exact(channel.chain_1.channel_id.clone()),
));

let filters_2 = packet_filters.entry(chain_2).or_insert(Vec::new());
let filters_2 = packet_filters.entry(chain_2).or_default();

filters_2.push((
FilterPattern::Exact(channel.chain_2.port_id.clone()),
Expand Down
14 changes: 7 additions & 7 deletions crates/relayer-cli/src/commands/clear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ mod tests {
key_name: None,
counterparty_key_name: None,
},
ClearPacketsCmd::parse_from(&[
ClearPacketsCmd::parse_from([
"test",
"--chain",
"chain_id",
Expand All @@ -193,7 +193,7 @@ mod tests {
key_name: None,
counterparty_key_name: None
},
ClearPacketsCmd::parse_from(&[
ClearPacketsCmd::parse_from([
"test",
"--chain",
"chain_id",
Expand All @@ -215,7 +215,7 @@ mod tests {
key_name: Some("key_name".to_owned()),
counterparty_key_name: None,
},
ClearPacketsCmd::parse_from(&[
ClearPacketsCmd::parse_from([
"test",
"--chain",
"chain_id",
Expand All @@ -239,7 +239,7 @@ mod tests {
key_name: None,
counterparty_key_name: Some("counterparty_key_name".to_owned()),
},
ClearPacketsCmd::parse_from(&[
ClearPacketsCmd::parse_from([
"test",
"--chain",
"chain_id",
Expand All @@ -255,15 +255,15 @@ mod tests {

#[test]
fn test_clear_packets_no_chan() {
assert!(ClearPacketsCmd::try_parse_from(&[
assert!(ClearPacketsCmd::try_parse_from([
"test", "--chain", "chain_id", "--port", "port_id"
])
.is_err())
}

#[test]
fn test_clear_packets_no_port() {
assert!(ClearPacketsCmd::try_parse_from(&[
assert!(ClearPacketsCmd::try_parse_from([
"test",
"--chain",
"chain_id",
Expand All @@ -275,7 +275,7 @@ mod tests {

#[test]
fn test_clear_packets_no_chain() {
assert!(ClearPacketsCmd::try_parse_from(&[
assert!(ClearPacketsCmd::try_parse_from([
"test",
"--port",
"port_id",
Expand Down
8 changes: 4 additions & 4 deletions crates/relayer-cli/src/commands/completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ mod tests {
fn test_completions() {
assert_eq!(
CompletionsCmd { shell: Shell::Zsh },
CompletionsCmd::parse_from(&["test", "--shell", "zsh"])
CompletionsCmd::parse_from(["test", "--shell", "zsh"])
)
}

#[test]
fn test_completions_no_shell() {
assert!(CompletionsCmd::try_parse_from(&["test", "--shell"]).is_err())
assert!(CompletionsCmd::try_parse_from(["test", "--shell"]).is_err())
}

#[test]
fn test_completions_no_shell_flag() {
assert!(CompletionsCmd::try_parse_from(&["test"]).is_err())
assert!(CompletionsCmd::try_parse_from(["test"]).is_err())
}

#[test]
fn test_completions_unknown_shell() {
assert!(CompletionsCmd::try_parse_from(&["test", "--shell", "my_shell"]).is_err())
assert!(CompletionsCmd::try_parse_from(["test", "--shell", "my_shell"]).is_err())
}
}
4 changes: 2 additions & 2 deletions crates/relayer-cli/src/commands/config/auto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ mod tests {
chain_names: vec!["chain1:key1".to_string(), "chain2".to_string()],
commit: None,
},
AutoCmd::parse_from(&[
AutoCmd::parse_from([
"test",
"--output",
"./example.toml",
Expand All @@ -175,7 +175,7 @@ mod tests {
chain_names: vec!["chain1:key1".to_string(), "chain2".to_string()],
commit: Some("test_commit".to_string()),
},
AutoCmd::parse_from(&[
AutoCmd::parse_from([
"test",
"--output",
"./example.toml",
Expand Down
30 changes: 15 additions & 15 deletions crates/relayer-cli/src/commands/create/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ mod tests {
new_client_connection: false,
yes: false
},
CreateChannelCommand::parse_from(&[
CreateChannelCommand::parse_from([
"test",
"--a-chain",
"chain_a",
Expand Down Expand Up @@ -322,7 +322,7 @@ mod tests {
new_client_connection: false,
yes: false
},
CreateChannelCommand::parse_from(&[
CreateChannelCommand::parse_from([
"test",
"--a-chain",
"chain_a",
Expand Down Expand Up @@ -352,7 +352,7 @@ mod tests {
new_client_connection: false,
yes: false
},
CreateChannelCommand::parse_from(&[
CreateChannelCommand::parse_from([
"test",
"--a-chain",
"chain_a",
Expand Down Expand Up @@ -382,7 +382,7 @@ mod tests {
new_client_connection: false,
yes: false
},
CreateChannelCommand::parse_from(&[
CreateChannelCommand::parse_from([
"test",
"--a-chain",
"chain_a",
Expand All @@ -398,7 +398,7 @@ mod tests {

#[test]
fn test_create_channel_a_conn_with_new_client_conn() {
assert!(CreateChannelCommand::try_parse_from(&[
assert!(CreateChannelCommand::try_parse_from([
"test",
"--a-chain",
"chain_a",
Expand All @@ -415,7 +415,7 @@ mod tests {

#[test]
fn test_create_channel_a_conn_with_yes() {
assert!(CreateChannelCommand::try_parse_from(&[
assert!(CreateChannelCommand::try_parse_from([
"test",
"--a-chain",
"chain_a",
Expand All @@ -436,7 +436,7 @@ mod tests {

#[test]
fn test_create_channel_a_conn_with_b_chain() {
assert!(CreateChannelCommand::try_parse_from(&[
assert!(CreateChannelCommand::try_parse_from([
"test",
"--a-chain",
"chain_a",
Expand Down Expand Up @@ -468,7 +468,7 @@ mod tests {
new_client_connection: true,
yes: false
},
CreateChannelCommand::parse_from(&[
CreateChannelCommand::parse_from([
"test",
"--a-chain",
"chain_a",
Expand Down Expand Up @@ -497,7 +497,7 @@ mod tests {
new_client_connection: true,
yes: true
},
CreateChannelCommand::parse_from(&[
CreateChannelCommand::parse_from([
"test",
"--a-chain",
"chain_a",
Expand Down Expand Up @@ -527,7 +527,7 @@ mod tests {
new_client_connection: true,
yes: false
},
CreateChannelCommand::parse_from(&[
CreateChannelCommand::parse_from([
"test",
"--a-chain",
"chain_a",
Expand All @@ -544,7 +544,7 @@ mod tests {

#[test]
fn test_create_channel_b_chain_without_new_client() {
assert!(CreateChannelCommand::try_parse_from(&[
assert!(CreateChannelCommand::try_parse_from([
"test",
"--a-chain",
"chain_a",
Expand All @@ -560,7 +560,7 @@ mod tests {

#[test]
fn test_create_channel_no_b_port() {
assert!(CreateChannelCommand::try_parse_from(&[
assert!(CreateChannelCommand::try_parse_from([
"test",
"--a-chain",
"chain_a",
Expand All @@ -576,7 +576,7 @@ mod tests {

#[test]
fn test_create_channel_no_a_port() {
assert!(CreateChannelCommand::try_parse_from(&[
assert!(CreateChannelCommand::try_parse_from([
"test",
"--a-chain",
"chain_a",
Expand All @@ -592,7 +592,7 @@ mod tests {

#[test]
fn test_create_channel_no_b_chain_nor_a_conn() {
assert!(CreateChannelCommand::try_parse_from(&[
assert!(CreateChannelCommand::try_parse_from([
"test",
"--a-chain",
"chain_a",
Expand All @@ -606,7 +606,7 @@ mod tests {

#[test]
fn test_create_channel_no_a_chain() {
assert!(CreateChannelCommand::try_parse_from(&[
assert!(CreateChannelCommand::try_parse_from([
"test",
"--b-chain",
"chain_b",
Expand Down
20 changes: 10 additions & 10 deletions crates/relayer-cli/src/commands/create/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ mod tests {
client_b: None,
delay: 0
},
CreateConnectionCommand::parse_from(&[
CreateConnectionCommand::parse_from([
"test",
"--a-chain",
"chain_a",
Expand All @@ -214,7 +214,7 @@ mod tests {
client_b: None,
delay: 42
},
CreateConnectionCommand::parse_from(&[
CreateConnectionCommand::parse_from([
"test",
"--a-chain",
"chain_a",
Expand All @@ -236,7 +236,7 @@ mod tests {
client_b: Some(ClientId::from_str("07-client_b").unwrap()),
delay: 0
},
CreateConnectionCommand::parse_from(&[
CreateConnectionCommand::parse_from([
"test",
"--a-chain",
"chain_a",
Expand All @@ -258,7 +258,7 @@ mod tests {
client_b: Some(ClientId::from_str("07-client_b").unwrap()),
delay: 42
},
CreateConnectionCommand::parse_from(&[
CreateConnectionCommand::parse_from([
"test",
"--a-chain",
"chain_a",
Expand All @@ -274,17 +274,17 @@ mod tests {

#[test]
fn test_create_connection_a_chain_only() {
assert!(CreateConnectionCommand::try_parse_from(&["test", "--a-chain", "chain_a"]).is_err())
assert!(CreateConnectionCommand::try_parse_from(["test", "--a-chain", "chain_a"]).is_err())
}

#[test]
fn test_create_connection_no_a_chain() {
assert!(CreateConnectionCommand::try_parse_from(&["test", "--b-chain", "chain_b"]).is_err())
assert!(CreateConnectionCommand::try_parse_from(["test", "--b-chain", "chain_b"]).is_err())
}

#[test]
fn test_create_connection_b_client_without_a_client() {
assert!(CreateConnectionCommand::try_parse_from(&[
assert!(CreateConnectionCommand::try_parse_from([
"test",
"--a-chain",
"chain_a",
Expand All @@ -296,7 +296,7 @@ mod tests {

#[test]
fn test_create_connection_a_client_required_without_b_client() {
assert!(CreateConnectionCommand::try_parse_from(&[
assert!(CreateConnectionCommand::try_parse_from([
"test",
"--a-chain",
"chain_a",
Expand All @@ -308,7 +308,7 @@ mod tests {

#[test]
fn test_create_connection_b_chain_with_a_client() {
assert!(CreateConnectionCommand::try_parse_from(&[
assert!(CreateConnectionCommand::try_parse_from([
"test",
"--a-chain",
"chain_a",
Expand All @@ -322,7 +322,7 @@ mod tests {

#[test]
fn test_create_connection_b_chain_with_b_client() {
assert!(CreateConnectionCommand::try_parse_from(&[
assert!(CreateConnectionCommand::try_parse_from([
"test",
"--a-chain",
"chain_a",
Expand Down
Loading

0 comments on commit 1c0d935

Please sign in to comment.