diff options
| author | David Lönnhager <david.l@mullvad.net> | 2022-08-12 16:15:09 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2022-08-29 13:14:08 +0200 |
| commit | b1cd9705063827ad06540854d9555b77ca44169a (patch) | |
| tree | bb4d7f78166a7cf26c027ad0669683cfdd569298 | |
| parent | 3bca72f9f698eafb75c3c9e0490096a4fbafb9fb (diff) | |
| download | mullvadvpn-b1cd9705063827ad06540854d9555b77ca44169a.tar.xz mullvadvpn-b1cd9705063827ad06540854d9555b77ca44169a.zip | |
Fix Clippy errors
| -rw-r--r-- | android/translations-converter/src/normalize.rs | 4 | ||||
| -rw-r--r-- | mullvad-api/src/lib.rs | 5 | ||||
| -rw-r--r-- | mullvad-api/src/proxy.rs | 4 | ||||
| -rw-r--r-- | mullvad-daemon/src/device/mod.rs | 8 | ||||
| -rw-r--r-- | mullvad-relay-selector/src/lib.rs | 3 | ||||
| -rw-r--r-- | mullvad-types/src/device.rs | 6 | ||||
| -rw-r--r-- | mullvad-types/src/settings/mod.rs | 4 | ||||
| -rw-r--r-- | mullvad-types/src/wireguard.rs | 4 | ||||
| -rw-r--r-- | talpid-core/src/tunnel/wireguard/stats.rs | 2 | ||||
| -rw-r--r-- | talpid-types/src/tunnel.rs | 14 |
10 files changed, 26 insertions, 28 deletions
diff --git a/android/translations-converter/src/normalize.rs b/android/translations-converter/src/normalize.rs index ffeddbc6f7..4896e6d25c 100644 --- a/android/translations-converter/src/normalize.rs +++ b/android/translations-converter/src/normalize.rs @@ -21,7 +21,7 @@ mod android { impl Normalize for StringValue { fn normalize(&self) -> String { // Unescape apostrophes - let value = APOSTROPHES.replace_all(&*self, "'"); + let value = APOSTROPHES.replace_all(self, "'"); // Unescape double quotes let value = DOUBLE_QUOTES.replace_all(&value, r#"""#); // Mark where parameters are positioned, removing the parameter index @@ -47,7 +47,7 @@ mod gettext { impl Normalize for MsgString { fn normalize(&self) -> String { // Use a single common apostrophe character - let string = APOSTROPHE_VARIATION.replace_all(&*self, "'"); + let string = APOSTROPHE_VARIATION.replace_all(self, "'"); // Mark where parameters are positioned, removing the parameter name let string = PARAMETERS.replace_all(&string, "%"); // Remove escaped single-quotes diff --git a/mullvad-api/src/lib.rs b/mullvad-api/src/lib.rs index b0222ca244..12ca3d45e4 100644 --- a/mullvad-api/src/lib.rs +++ b/mullvad-api/src/lib.rs @@ -236,7 +236,7 @@ impl Runtime { new_address_callback: impl ApiEndpointUpdateCallback + Send + Sync + 'static, #[cfg(target_os = "android")] socket_bypass_tx: Option<mpsc::Sender<SocketBypassRequest>>, ) -> rest::RequestServiceHandle { - let service_handle = rest::RequestService::spawn( + rest::RequestService::spawn( sni_hostname, self.api_availability.handle(), self.address_cache.clone(), @@ -245,8 +245,7 @@ impl Runtime { #[cfg(target_os = "android")] socket_bypass_tx, ) - .await; - service_handle + .await } /// Returns a request factory initialized to create requests for the master API diff --git a/mullvad-api/src/proxy.rs b/mullvad-api/src/proxy.rs index cc7ee3aa6c..2f3764e7e6 100644 --- a/mullvad-api/src/proxy.rs +++ b/mullvad-api/src/proxy.rs @@ -19,7 +19,7 @@ use tokio::{ const CURRENT_CONFIG_FILENAME: &str = "api-endpoint.json"; -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] pub enum ApiConnectionMode { /// Connect directly to the target. Direct, @@ -36,7 +36,7 @@ impl fmt::Display for ApiConnectionMode { } } -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] pub enum ProxyConfig { Shadowsocks(ShadowsocksProxySettings), } diff --git a/mullvad-daemon/src/device/mod.rs b/mullvad-daemon/src/device/mod.rs index 93dbac49ca..aa301ca85d 100644 --- a/mullvad-daemon/src/device/mod.rs +++ b/mullvad-daemon/src/device/mod.rs @@ -74,7 +74,7 @@ pub enum Error { } /// Contains the current device state. -#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] #[serde(rename_all = "snake_case")] pub enum PrivateDeviceState { LoggedIn(PrivateAccountAndDevice), @@ -135,7 +135,7 @@ impl From<PrivateDeviceState> for DeviceState { } /// Same as [PrivateDevice] but also contains the associated account token. -#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] pub struct PrivateAccountAndDevice { pub account_token: AccountToken, pub device: PrivateDevice, @@ -151,7 +151,7 @@ impl From<PrivateAccountAndDevice> for AccountAndDevice { } /// Device type that contains private data. -#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] pub struct PrivateDevice { pub id: DeviceId, pub name: DeviceName, @@ -281,7 +281,7 @@ impl Error { pub fn unpack(&self) -> &Error { if let Error::ResponseFailure(ref inner) = self { - &*inner + inner } else { self } diff --git a/mullvad-relay-selector/src/lib.rs b/mullvad-relay-selector/src/lib.rs index bed781eff7..94725e767e 100644 --- a/mullvad-relay-selector/src/lib.rs +++ b/mullvad-relay-selector/src/lib.rs @@ -1116,7 +1116,7 @@ impl RelaySelector { relays: &'a [RelayType], weight_fn: impl Fn(&RelayType) -> u64, ) -> Option<&'a RelayType> { - let total_weight: u64 = relays.iter().map(|relay| weight_fn(relay)).sum(); + let total_weight: u64 = relays.iter().map(&weight_fn).sum(); let mut rng = rand::thread_rng(); if total_weight == 0 { relays.choose(&mut rng) @@ -1131,7 +1131,6 @@ impl RelaySelector { i = i.saturating_sub(weight_fn(relay)); i == 0 }) - .map(|relay| relay) .expect("At least one relay must've had a weight above 0"), ) } diff --git a/mullvad-types/src/device.rs b/mullvad-types/src/device.rs index 38dd528fd5..dd513ea6f1 100644 --- a/mullvad-types/src/device.rs +++ b/mullvad-types/src/device.rs @@ -52,7 +52,7 @@ impl Device { } /// Ports associated with a device. -#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] #[cfg_attr(target_os = "android", derive(IntoJava))] #[cfg_attr(target_os = "android", jnix(package = "net.mullvad.mullvadvpn.model"))] pub struct DevicePort { @@ -67,7 +67,7 @@ impl fmt::Display for DevicePort { } /// Contains a device state. -#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] #[serde(rename_all = "snake_case")] #[cfg_attr(target_os = "android", derive(IntoJava))] #[cfg_attr(target_os = "android", jnix(package = "net.mullvad.mullvadvpn.model"))] @@ -87,7 +87,7 @@ impl DeviceState { } /// A [Device] and its associated account token. -#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] #[cfg_attr(target_os = "android", derive(IntoJava))] #[cfg_attr(target_os = "android", jnix(package = "net.mullvad.mullvadvpn.model"))] pub struct AccountAndDevice { diff --git a/mullvad-types/src/settings/mod.rs b/mullvad-types/src/settings/mod.rs index d7cc62e605..70bef31245 100644 --- a/mullvad-types/src/settings/mod.rs +++ b/mullvad-types/src/settings/mod.rs @@ -22,7 +22,7 @@ mod dns; /// being added to `mullvad-daemon`. pub const CURRENT_SETTINGS_VERSION: SettingsVersion = SettingsVersion::V6; -#[derive(Debug, PartialEq, PartialOrd, Clone, Copy)] +#[derive(Debug, PartialEq, Eq, PartialOrd, Clone, Copy)] #[repr(u32)] pub enum SettingsVersion { V2 = 2, @@ -107,7 +107,7 @@ fn out_of_range_wg_migration_rand_num() -> f32 { } #[cfg(windows)] -#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, Eq)] pub struct SplitTunnelSettings { /// Toggles split tunneling on or off pub enable_exclusions: bool, diff --git a/mullvad-types/src/wireguard.rs b/mullvad-types/src/wireguard.rs index 612becf010..a02d973ba5 100644 --- a/mullvad-types/src/wireguard.rs +++ b/mullvad-types/src/wireguard.rs @@ -15,7 +15,7 @@ pub const DEFAULT_ROTATION_INTERVAL: Duration = if cfg!(target_os = "android") { }; /// Contains account specific wireguard data -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] pub struct WireguardData { pub private_key: wireguard::PrivateKey, pub addresses: AssociatedAddresses, @@ -142,7 +142,7 @@ pub struct PublicKey { /// Contains a pair of local link addresses that are paired with a specific wireguard /// public/private keypair. -#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub struct AssociatedAddresses { pub ipv4_address: ipnetwork::Ipv4Network, pub ipv6_address: ipnetwork::Ipv6Network, diff --git a/talpid-core/src/tunnel/wireguard/stats.rs b/talpid-core/src/tunnel/wireguard/stats.rs index cec033f611..bd7b578545 100644 --- a/talpid-core/src/tunnel/wireguard/stats.rs +++ b/talpid-core/src/tunnel/wireguard/stats.rs @@ -17,7 +17,7 @@ pub enum Error { } /// Contains bytes sent and received through a tunnel -#[derive(Default, Debug, PartialEq, Clone, Copy)] +#[derive(Default, Debug, PartialEq, Eq, Clone, Copy)] pub struct Stats { pub tx_bytes: u64, pub rx_bytes: u64, diff --git a/talpid-types/src/tunnel.rs b/talpid-types/src/tunnel.rs index af84e35390..b3eadeda9a 100644 --- a/talpid-types/src/tunnel.rs +++ b/talpid-types/src/tunnel.rs @@ -8,7 +8,7 @@ use std::net::IpAddr; /// Event emitted from the states in `talpid_core::tunnel_state_machine` when the tunnel state /// machine enters a new state. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum TunnelStateTransition { /// No connection is established and network is unsecured. Disconnected, @@ -23,7 +23,7 @@ pub enum TunnelStateTransition { } /// Action that will be taken after disconnection is complete. -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] #[cfg_attr(target_os = "android", derive(IntoJava))] #[cfg_attr(target_os = "android", jnix(package = "net.mullvad.talpid.tunnel"))] @@ -34,7 +34,7 @@ pub enum ActionAfterDisconnect { } /// Represents the tunnel state machine entering an error state during a [`TunnelStateTransition`]. -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] #[cfg_attr(target_os = "android", derive(IntoJava))] #[cfg_attr(target_os = "android", jnix(package = "net.mullvad.talpid.tunnel"))] @@ -75,7 +75,7 @@ impl ErrorState { } /// Reason for the tunnel state machine entering an [`ErrorState`]. -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] #[serde(tag = "reason", content = "details")] #[cfg_attr(target_os = "android", derive(IntoJava))] @@ -117,7 +117,7 @@ impl ErrorStateCause { } /// Errors that can occur when generating tunnel parameters. -#[derive(err_derive::Error, Debug, Serialize, Clone, PartialEq, Deserialize)] +#[derive(err_derive::Error, Debug, Serialize, Clone, PartialEq, Eq, Deserialize)] #[serde(rename_all = "snake_case")] #[cfg_attr(target_os = "android", derive(IntoJava))] #[cfg_attr(target_os = "android", jnix(package = "net.mullvad.talpid.tunnel"))] @@ -138,14 +138,14 @@ pub enum ParameterGenerationError { /// Application that prevents setting the firewall policy. #[cfg(windows)] -#[derive(Debug, Serialize, Clone, PartialEq, Deserialize)] +#[derive(Debug, Serialize, Clone, PartialEq, Eq, Deserialize)] pub struct BlockingApplication { pub name: String, pub pid: u32, } /// Errors that can occur when setting the firewall policy. -#[derive(err_derive::Error, Debug, Serialize, Clone, PartialEq, Deserialize)] +#[derive(err_derive::Error, Debug, Serialize, Clone, PartialEq, Eq, Deserialize)] #[serde(rename_all = "snake_case")] #[serde(tag = "reason", content = "details")] #[cfg_attr(target_os = "android", derive(IntoJava))] |
