diff --git a/examples/autonat_client.rs b/examples/autonat_client.rs index 17fb1037203..c90a5c55060 100644 --- a/examples/autonat_client.rs +++ b/examples/autonat_client.rs @@ -117,6 +117,7 @@ impl Behaviour { } #[derive(Debug)] +#[allow(clippy::large_enum_variant)] enum Event { AutoNat(autonat::Event), Identify(identify::Event), diff --git a/examples/autonat_server.rs b/examples/autonat_server.rs index 72592be7082..7bb79383710 100644 --- a/examples/autonat_server.rs +++ b/examples/autonat_server.rs @@ -96,6 +96,7 @@ impl Behaviour { } #[derive(Debug)] +#[allow(clippy::large_enum_variant)] enum Event { AutoNat(autonat::Event), Identify(identify::Event), diff --git a/tests/test_client.rs b/tests/test_client.rs index 72088f6e232..420bcf99829 100644 --- a/tests/test_client.rs +++ b/tests/test_client.rs @@ -58,9 +58,8 @@ async fn spawn_server(kill: oneshot::Receiver<()>) -> (PeerId, Multiaddr) { .listen_on("/ip4/0.0.0.0/tcp/0".parse().unwrap()) .unwrap(); let addr = loop { - match server.select_next_some().await { - SwarmEvent::NewListenAddr { address, .. } => break address, - _ => {} + if let SwarmEvent::NewListenAddr { address, .. } = server.select_next_some().await { + break address; }; }; tx.send((peer_id, addr)).unwrap(); @@ -78,11 +77,8 @@ async fn spawn_server(kill: oneshot::Receiver<()>) -> (PeerId, Multiaddr) { async fn next_event(swarm: &mut Swarm) -> Event { loop { - match swarm.select_next_some().await { - SwarmEvent::Behaviour(event) => { - break event; - } - _ => {} + if let SwarmEvent::Behaviour(event) = swarm.select_next_some().await { + break event; } } } @@ -177,9 +173,8 @@ async fn test_auto_probe() { .listen_on("/ip4/0.0.0.0/tcp/0".parse().unwrap()) .unwrap(); loop { - match client.select_next_some().await { - SwarmEvent::NewListenAddr { .. } => break, - _ => {} + if let SwarmEvent::NewListenAddr { .. } = client.select_next_some().await { + break; } } @@ -269,14 +264,13 @@ async fn test_confidence() { .listen_on("/ip4/0.0.0.0/tcp/0".parse().unwrap()) .unwrap(); loop { - match client.select_next_some().await { - SwarmEvent::NewListenAddr { .. } => break, - _ => {} + if let SwarmEvent::NewListenAddr { .. } = client.select_next_some().await { + break; } } } else { let unreachable_addr: Multiaddr = "/ip4/127.0.0.1/tcp/42".parse().unwrap(); - client.add_external_address(unreachable_addr.clone(), AddressScore::Infinite); + client.add_external_address(unreachable_addr, AddressScore::Infinite); } for i in 0..MAX_CONFIDENCE + 1 { @@ -357,9 +351,8 @@ async fn test_throttle_server_period() { .listen_on("/ip4/0.0.0.0/tcp/0".parse().unwrap()) .unwrap(); loop { - match client.select_next_some().await { - SwarmEvent::NewListenAddr { .. } => break, - _ => {} + if let SwarmEvent::NewListenAddr { .. } = client.select_next_some().await { + break; } } @@ -477,9 +470,8 @@ async fn test_outbound_failure() { .unwrap(); loop { - match client.select_next_some().await { - SwarmEvent::NewListenAddr { .. } => break, - _ => {} + if let SwarmEvent::NewListenAddr { .. } = client.select_next_some().await { + break; } } // First probe should be successful and flip status to public. @@ -497,7 +489,8 @@ async fn test_outbound_failure() { } let inactive = servers.split_off(1); - // Drop the handles of the inactive servers to kill them. + + #[allow(clippy::needless_collect)] // Drop the handles of the inactive servers to kill them. let inactive_ids: Vec<_> = inactive.into_iter().map(|(id, _handle)| id).collect(); // Expect to retry on outbound failure @@ -541,9 +534,8 @@ async fn test_global_ips_config() { .listen_on("/ip4/0.0.0.0/tcp/0".parse().unwrap()) .unwrap(); loop { - match client.select_next_some().await { - SwarmEvent::NewListenAddr { .. } => break, - _ => {} + if let SwarmEvent::NewListenAddr { .. } = client.select_next_some().await { + break; } } diff --git a/tests/test_server.rs b/tests/test_server.rs index ffe2aa3ea3d..b45ae7ecafc 100644 --- a/tests/test_server.rs +++ b/tests/test_server.rs @@ -56,9 +56,8 @@ async fn init_server(config: Option) -> (Swarm, PeerId, Multi .listen_on("/ip4/0.0.0.0/tcp/0".parse().unwrap()) .unwrap(); let addr = loop { - match server.select_next_some().await { - SwarmEvent::NewListenAddr { address, .. } => break address, - _ => {} + if let SwarmEvent::NewListenAddr { address, .. } = server.select_next_some().await { + break address; }; }; (server, peer_id, addr) @@ -91,12 +90,9 @@ async fn spawn_client( .listen_on("/ip4/0.0.0.0/tcp/0".parse().unwrap()) .unwrap(); loop { - match client.select_next_some().await { - SwarmEvent::NewListenAddr { address, .. } => { - addr = Some(address); - break; - } - _ => {} + if let SwarmEvent::NewListenAddr { address, .. } = client.select_next_some().await { + addr = Some(address); + break; }; } } @@ -119,11 +115,8 @@ async fn spawn_client( async fn next_event(swarm: &mut Swarm) -> Event { loop { - match swarm.select_next_some().await { - SwarmEvent::Behaviour(event) => { - break event; - } - _ => {} + if let SwarmEvent::Behaviour(event) = swarm.select_next_some().await { + break event; } } } @@ -161,9 +154,8 @@ async fn test_dial_back() { } => { assert_eq!(peer_id, client_id); let observed_client_ip = loop { - match send_back_addr.pop().unwrap() { - Protocol::Ip4(ip4_addr) => break ip4_addr, - _ => {} + if let Protocol::Ip4(ip4_addr) = send_back_addr.pop().unwrap() { + break ip4_addr; } }; break observed_client_ip;