From a160b3b5daa83a52805631233261d5fb13f9e412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20L=C3=B6nnhager?= Date: Fri, 29 Dec 2023 18:10:03 +0100 Subject: [PATCH] Fix clippy lints --- mullvad-api/src/rest.rs | 2 +- mullvad-daemon/src/access_method.rs | 12 ++++++------ mullvad-daemon/src/migrations/account_history.rs | 6 +++--- mullvad-daemon/src/migrations/mod.rs | 6 +++--- mullvad-exclude/src/main.rs | 6 +++--- talpid-openvpn/src/proxy/shadowsocks.rs | 2 +- talpid-routing/src/windows/get_best_default_route.rs | 2 +- talpid-routing/src/windows/mod.rs | 2 +- talpid-routing/src/windows/route_manager.rs | 2 +- talpid-tunnel-config-client/src/lib.rs | 2 +- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/mullvad-api/src/rest.rs b/mullvad-api/src/rest.rs index 559ddd4b4e53..6332c1266e99 100644 --- a/mullvad-api/src/rest.rs +++ b/mullvad-api/src/rest.rs @@ -685,7 +685,7 @@ impl MullvadRestHandle { } match api_proxy.clone().get_api_addrs().await { Ok(new_addrs) => { - if let Some(addr) = new_addrs.get(0) { + if let Some(addr) = new_addrs.first() { log::debug!( "Fetched new API address {:?}. Fetching again in {} hours", addr, diff --git a/mullvad-daemon/src/access_method.rs b/mullvad-daemon/src/access_method.rs index 7d9d3dba95d0..028e54f462bb 100644 --- a/mullvad-daemon/src/access_method.rs +++ b/mullvad-daemon/src/access_method.rs @@ -22,13 +22,13 @@ pub enum Error { NoSuchMethod(access_method::Id), /// Access method could not be rotate #[error(display = "Access method could not be rotated")] - RotationError, + RotationFailed, /// Some error occured in the daemon's state of handling /// [`AccessMethodSetting`]s & [`ApiConnectionMode`]s. #[error(display = "Error occured when handling connection settings & details")] ConnectionMode(#[error(source)] api::Error), #[error(display = "API endpoint rotation failed")] - RestError(#[error(source)] rest::Error), + Rest(#[error(source)] rest::Error), /// Access methods settings error #[error(display = "Settings error")] Settings(#[error(source)] settings::Error), @@ -190,7 +190,7 @@ where .await .map_err(|error| { log::error!("Failed to rotate API endpoint: {}", error); - Error::RotationError + Error::RotationFailed }) } @@ -261,7 +261,7 @@ pub async fn test_access_method( .await .map_err(|err| { log::error!("Failed to rotate API endpoint: {err}"); - Error::RestError(err) + Error::Rest(err) })?; // Set up the reset @@ -289,7 +289,7 @@ pub async fn test_access_method( let result = mullvad_api::ApiProxy::new(rest_handle) .api_addrs_available() .await - .map_err(Error::RestError)?; + .map_err(Error::Rest)?; // We need to perform a rotation of API endpoint after a set action // Note that this will be done automatically if the API call fails, @@ -301,7 +301,7 @@ pub async fn test_access_method( .await .map_err(|err| { log::error!("Failed to rotate API endpoint: {err}"); - Error::RestError(err) + Error::Rest(err) })?; } diff --git a/mullvad-daemon/src/migrations/account_history.rs b/mullvad-daemon/src/migrations/account_history.rs index d007c1414f3a..fb1691fb75c4 100644 --- a/mullvad-daemon/src/migrations/account_history.rs +++ b/mullvad-daemon/src/migrations/account_history.rs @@ -79,7 +79,7 @@ fn migrate_formats_inner( } else if let Ok(token) = try_format_v1(account_bytes) { Ok(token) } else { - Err(Error::ParseHistoryError) + Err(Error::ParseHistory) } } @@ -110,7 +110,7 @@ fn try_format_v2(bytes: &[u8]) -> Result>(bytes) - .map_err(|_error| Error::ParseHistoryError)? + .map_err(|_error| Error::ParseHistory)? .into_iter() .next() .map(|entry| (entry.account, entry.wireguard))) @@ -122,7 +122,7 @@ fn try_format_v1(bytes: &[u8]) -> Result> { accounts: Vec, } Ok(serde_json::from_slice::<'_, OldFormat>(bytes) - .map_err(|_error| Error::ParseHistoryError)? + .map_err(|_error| Error::ParseHistory)? .accounts .into_iter() .next()) diff --git a/mullvad-daemon/src/migrations/mod.rs b/mullvad-daemon/src/migrations/mod.rs index 8624677f069b..e6977d9e2209 100644 --- a/mullvad-daemon/src/migrations/mod.rs +++ b/mullvad-daemon/src/migrations/mod.rs @@ -85,11 +85,11 @@ pub enum Error { WriteHistory(#[error(source)] io::Error), #[error(display = "Failed to parse account history")] - ParseHistoryError, + ParseHistory, #[cfg(windows)] #[error(display = "Failed to restore Windows update backup")] - WinMigrationError(#[error(source)] windows::Error), + WinMigration(#[error(source)] windows::Error), } pub type Result = std::result::Result; @@ -119,7 +119,7 @@ pub async fn migrate_all(cache_dir: &Path, settings_dir: &Path) -> Result