summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSebastian Holmin <sebastian.holmin@mullvad.net>2025-02-07 16:06:32 +0100
committerSebastian Holmin <sebastian.holmin@mullvad.net>2025-02-12 10:15:03 +0100
commit353119ad276a7bfd771f1bf93e56f1a4b27358db (patch)
tree85ab423459f54b2ff42affda95bd1a487b847597
parent92d61b5118be6fb5510f99393b38f40b25cc8abf (diff)
downloadmullvadvpn-353119ad276a7bfd771f1bf93e56f1a4b27358db.tar.xz
mullvadvpn-353119ad276a7bfd771f1bf93e56f1a4b27358db.zip
Run `cargo +beta fix --edition`
-rw-r--r--mullvad-cli/src/cmds/relay.rs8
-rw-r--r--mullvad-cli/src/format.rs6
-rw-r--r--mullvad-daemon/src/device/api.rs12
-rw-r--r--mullvad-daemon/src/device/mod.rs20
-rw-r--r--mullvad-daemon/src/device/service.rs6
-rw-r--r--mullvad-daemon/src/lib.rs30
-rw-r--r--mullvad-daemon/src/management_interface.rs4
-rw-r--r--mullvad-daemon/src/migrations/account_history.rs6
-rw-r--r--mullvad-daemon/src/settings/mod.rs6
-rw-r--r--mullvad-daemon/src/settings/patch.rs8
-rw-r--r--mullvad-daemon/src/version_check.rs4
11 files changed, 55 insertions, 55 deletions
diff --git a/mullvad-cli/src/cmds/relay.rs b/mullvad-cli/src/cmds/relay.rs
index d0de98c27a..b56c2c2991 100644
--- a/mullvad-cli/src/cmds/relay.rs
+++ b/mullvad-cli/src/cmds/relay.rs
@@ -941,10 +941,10 @@ pub async fn resolve_location_constraint(
relay_filter: impl FnOnce(&mullvad_types::relay_list::Relay) -> bool,
) -> Result<Constraint<GeographicLocationConstraint>> {
let relay_iter = rpc.get_relay_locations().await?.into_relays();
- if let Some(matching_relay) = relay_iter
+ match relay_iter
.clone()
.find(|relay| relay.hostname.to_lowercase() == location_constraint_args.country)
- {
+ { Some(matching_relay) => {
if relay_filter(&matching_relay) {
Ok(Constraint::Only(relay_to_geographical_constraint(
matching_relay,
@@ -955,7 +955,7 @@ pub async fn resolve_location_constraint(
location_constraint_args.country
)
}
- } else {
+ } _ => {
// The Constraint was not a relay, assuming it to be a location
let location_constraint: Constraint<GeographicLocationConstraint> =
Constraint::from(location_constraint_args);
@@ -970,7 +970,7 @@ pub async fn resolve_location_constraint(
}
Ok(location_constraint)
- }
+ }}
}
/// Return a list of all relays that are active and not bridges
diff --git a/mullvad-cli/src/format.rs b/mullvad-cli/src/format.rs
index fdf105e51f..3292f7eb71 100644
--- a/mullvad-cli/src/format.rs
+++ b/mullvad-cli/src/format.rs
@@ -12,13 +12,13 @@ use talpid_types::{
#[macro_export]
macro_rules! print_option {
- ($value:expr $(,)?) => {{
+ ($value:expr_2021 $(,)?) => {{
println!("{:<4}{:<24}{}", "", "", $value,)
}};
- ($option:literal, $value:expr $(,)?) => {{
+ ($option:literal, $value:expr_2021 $(,)?) => {{
println!("{:<4}{:<24}{}", "", concat!($option, ":"), $value,)
}};
- ($option:expr, $value:expr $(,)?) => {{
+ ($option:expr_2021, $value:expr_2021 $(,)?) => {{
println!("{:<4}{:<24}{}", "", format!("{}:", $option), $value,)
}};
}
diff --git a/mullvad-daemon/src/device/api.rs b/mullvad-daemon/src/device/api.rs
index d7b73d6e7b..f333142308 100644
--- a/mullvad-daemon/src/device/api.rs
+++ b/mullvad-daemon/src/device/api.rs
@@ -152,25 +152,25 @@ impl futures::Future for Call {
use Call::*;
match &mut *self {
Login(call, tx) => {
- if let std::task::Poll::Ready(response) = Pin::new(call).poll(cx) {
+ match Pin::new(call).poll(cx) { std::task::Poll::Ready(response) => {
std::task::Poll::Ready(ApiResult::Login(response, tx.take().unwrap()))
- } else {
+ } _ => {
std::task::Poll::Pending
- }
+ }}
}
TimerKeyRotation(call) | OneshotKeyRotation(call) => {
Pin::new(call).poll(cx).map(ApiResult::Rotation)
}
Validation(call) => Pin::new(call).poll(cx).map(ApiResult::Validation),
VoucherSubmission(call, tx) => {
- if let std::task::Poll::Ready(response) = Pin::new(call).poll(cx) {
+ match Pin::new(call).poll(cx) { std::task::Poll::Ready(response) => {
std::task::Poll::Ready(ApiResult::VoucherSubmission(
response,
tx.take().unwrap(),
))
- } else {
+ } _ => {
std::task::Poll::Pending
- }
+ }}
}
#[cfg(target_os = "android")]
InitPlayPurchase(call, tx) => {
diff --git a/mullvad-daemon/src/device/mod.rs b/mullvad-daemon/src/device/mod.rs
index 829b3f2060..80f6243ac8 100644
--- a/mullvad-daemon/src/device/mod.rs
+++ b/mullvad-daemon/src/device/mod.rs
@@ -945,7 +945,7 @@ impl AccountManager {
fn spawn_timed_key_rotation(
&self,
- ) -> Option<impl Future<Output = Result<WireguardData, Error>> + Send + 'static> {
+ ) -> Option<impl Future<Output = Result<WireguardData, Error>> + Send + 'static + use<>> {
let config = self.data.device()?;
let key_rotation_timer = self.key_rotation_timer(config.device.wg_data.created);
@@ -1002,20 +1002,20 @@ impl AccountManager {
.is_ok()
});
- if let Some(old_config) = old_config {
+ match old_config { Some(old_config) => {
let logout_call = tokio::spawn(Box::pin(self.logout_api_call(old_config)));
tokio::spawn(async move {
let _response = tokio::time::timeout(LOGOUT_TIMEOUT, logout_call).await;
let _ = tx.send(Ok(()));
});
- } else {
+ } _ => {
// The state was `revoked`.
let _ = tx.send(Ok(()));
- }
+ }}
}
- fn logout_api_call(&self, data: PrivateAccountAndDevice) -> impl Future<Output = ()> + 'static {
+ fn logout_api_call(&self, data: PrivateAccountAndDevice) -> impl Future<Output = ()> + 'static + use<> {
let service = self.device_service.clone();
async move {
@@ -1057,7 +1057,7 @@ impl AccountManager {
fn initiate_key_rotation(
&self,
- ) -> Result<impl Future<Output = Result<WireguardData, Error>>, Error> {
+ ) -> Result<impl Future<Output = Result<WireguardData, Error>> + use<>, Error> {
let data = self.data.device().cloned().ok_or(Error::NoDevice)?;
let device_service = self.device_service.clone();
Ok(async move {
@@ -1067,7 +1067,7 @@ impl AccountManager {
})
}
- fn key_rotation_timer(&self, key_created: DateTime<Utc>) -> impl Future<Output = ()> + 'static {
+ fn key_rotation_timer(&self, key_created: DateTime<Utc>) -> impl Future<Output = ()> + 'static + use<> {
let rotation_interval = self.rotation_interval;
async move {
@@ -1097,21 +1097,21 @@ impl AccountManager {
fn fetch_device_config(
&self,
old_config: &PrivateAccountAndDevice,
- ) -> impl Future<Output = Result<Device, Error>> {
+ ) -> impl Future<Output = Result<Device, Error>> + use<> {
let device_service = self.device_service.clone();
let account_number = old_config.account_number.clone();
let device_id = old_config.device.id.clone();
async move { device_service.get(account_number, device_id).await }
}
- fn validation_call(&self) -> Result<impl Future<Output = Result<Device, Error>>, Error> {
+ fn validation_call(&self) -> Result<impl Future<Output = Result<Device, Error>> + use<>, Error> {
let old_config = self.data.device().ok_or(Error::NoDevice)?;
Ok(self.fetch_device_config(old_config))
}
fn expiry_call(
&self,
- ) -> Result<impl Future<Output = Result<chrono::DateTime<Utc>, Error>>, Error> {
+ ) -> Result<impl Future<Output = Result<chrono::DateTime<Utc>, Error>> + use<>, Error> {
let old_config = self.data.device().ok_or(Error::NoDevice)?;
let account_number = old_config.account_number.clone();
let account_service = self.account_service.clone();
diff --git a/mullvad-daemon/src/device/service.rs b/mullvad-daemon/src/device/service.rs
index b5d8fcd3b3..39fbb469f9 100644
--- a/mullvad-daemon/src/device/service.rs
+++ b/mullvad-daemon/src/device/service.rs
@@ -44,7 +44,7 @@ impl DeviceService {
pub fn generate_for_account(
&self,
account_number: AccountNumber,
- ) -> impl Future<Output = Result<PrivateAccountAndDevice, Error>> + Send {
+ ) -> impl Future<Output = Result<PrivateAccountAndDevice, Error>> + Send + use<> {
let private_key = PrivateKey::new_from_random();
let pubkey = private_key.public_key();
@@ -261,7 +261,7 @@ pub struct AccountService {
}
impl AccountService {
- pub fn create_account(&self) -> impl Future<Output = Result<AccountNumber, rest::Error>> {
+ pub fn create_account(&self) -> impl Future<Output = Result<AccountNumber, rest::Error>> + use<> {
let proxy = self.proxy.clone();
let api_handle = self.api_availability.clone();
retry_future(
@@ -274,7 +274,7 @@ impl AccountService {
pub fn get_www_auth_token(
&self,
account: AccountNumber,
- ) -> impl Future<Output = Result<String, rest::Error>> {
+ ) -> impl Future<Output = Result<String, rest::Error>> + use<> {
let proxy = self.proxy.clone();
let api_handle = self.api_availability.clone();
retry_future(
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs
index 6e91e6efa1..be2792e845 100644
--- a/mullvad-daemon/src/lib.rs
+++ b/mullvad-daemon/src/lib.rs
@@ -560,13 +560,13 @@ where
InternalDaemonEvent: From<E>,
{
fn send(&self, event: E) -> Result<(), talpid_core::mpsc::Error> {
- if let Some(sender) = self.sender.upgrade() {
+ match self.sender.upgrade() { Some(sender) => {
sender
.unbounded_send(InternalDaemonEvent::from(event))
.map_err(|_| talpid_core::mpsc::Error::ChannelClosed)
- } else {
+ } _ => {
Err(talpid_core::mpsc::Error::ChannelClosed)
- }
+ }}
}
}
@@ -958,11 +958,11 @@ impl Daemon {
self.disconnect_tunnel();
while let Some(event) = self.rx.next().await {
- if let InternalDaemonEvent::TunnelStateTransition(transition) = event {
+ match event { InternalDaemonEvent::TunnelStateTransition(transition) => {
self.handle_tunnel_state_transition(transition).await;
- } else {
+ } _ => {
log::trace!("Ignoring event because the daemon is shutting down");
- }
+ }}
if self.tunnel_state.is_disconnected() {
break;
@@ -1162,15 +1162,15 @@ impl Daemon {
// If not connected, we have to guess whether the users local connection supports IPv6.
// The only thing we have to go on is the wireguard setting.
TunnelState::Disconnected { .. } => {
- if let RelaySettings::Normal(relay_constraints) = &self.settings.relay_settings {
+ match &self.settings.relay_settings { RelaySettings::Normal(relay_constraints) => {
// Note that `Constraint::Any` corresponds to just IPv4
matches!(
relay_constraints.wireguard_constraints.ip_version,
mullvad_types::constraints::Constraint::Only(IpVersion::V6)
)
- } else {
+ } _ => {
false
- }
+ }}
}
// Fetching IP from am.i.mullvad.net should only be done from a tunnel state where a
// connection is available. Otherwise we just exist.
@@ -1690,7 +1690,7 @@ impl Daemon {
}
async fn on_get_www_auth_token(&mut self, tx: ResponseTx<String, Error>) {
- if let Ok(Some(device)) = self.account_manager.data().await.map(|s| s.into_device()) {
+ match self.account_manager.data().await.map(|s| s.into_device()) { Ok(Some(device)) => {
let future = self
.account_manager
.account_service
@@ -1702,13 +1702,13 @@ impl Daemon {
"get_www_auth_token response",
);
});
- } else {
+ } _ => {
Self::oneshot_send(
tx,
Err(Error::NoAccountNumber),
"get_www_auth_token response",
);
- }
+ }}
}
fn on_submit_voucher(&mut self, tx: ResponseTx<VoucherSubmission, Error>, voucher: String) {
@@ -2710,11 +2710,11 @@ impl Daemon {
async fn on_get_wireguard_key(&self, tx: ResponseTx<Option<PublicKey>, Error>) {
let result =
- if let Ok(Some(config)) = self.account_manager.data().await.map(|s| s.into_device()) {
+ match self.account_manager.data().await.map(|s| s.into_device()) { Ok(Some(config)) => {
Ok(Some(config.device.wg_data.get_public_key()))
- } else {
+ } _ => {
Err(Error::NoAccountNumber)
- };
+ }};
Self::oneshot_send(tx, result, "get_wireguard_key response");
}
diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs
index 817dc85200..d8df3e50ef 100644
--- a/mullvad-daemon/src/management_interface.rs
+++ b/mullvad-daemon/src/management_interface.rs
@@ -1138,7 +1138,7 @@ impl ManagementInterfaceServer {
let rpc_server_join_handle = mullvad_management_interface::spawn_rpc_server(
server,
async move {
- server_abort_rx.into_future().await;
+ StreamExt::into_future(server_abort_rx).await;
},
&rpc_socket_path,
)
@@ -1353,7 +1353,7 @@ fn map_device_error(error: &device::Error) -> Status {
}
device::Error::InvalidVoucher => Status::new(Code::NotFound, INVALID_VOUCHER_MESSAGE),
device::Error::UsedVoucher => Status::new(Code::ResourceExhausted, USED_VOUCHER_MESSAGE),
- device::Error::DeviceIoError(ref _error) => {
+ &device::Error::DeviceIoError(ref _error) => {
Status::new(Code::Unavailable, error.to_string())
}
device::Error::OtherRestError(error) => map_rest_error(error),
diff --git a/mullvad-daemon/src/migrations/account_history.rs b/mullvad-daemon/src/migrations/account_history.rs
index eeaf6e67d7..1008261136 100644
--- a/mullvad-daemon/src/migrations/account_history.rs
+++ b/mullvad-daemon/src/migrations/account_history.rs
@@ -25,14 +25,14 @@ pub async fn migrate_location(old_dir: &Path, new_dir: &Path) {
return;
}
- if let Err(error) = fs::copy(&old_path, &new_path).await {
+ match fs::copy(&old_path, &new_path).await { Err(error) => {
log::error!(
"{}",
error.display_chain_with_msg("Failed to migrate account history file location")
);
- } else {
+ } _ => {
let _ = fs::remove_file(old_path).await;
- }
+ }}
}
pub async fn migrate_formats(settings_dir: &Path, settings: &mut serde_json::Value) -> Result<()> {
diff --git a/mullvad-daemon/src/settings/mod.rs b/mullvad-daemon/src/settings/mod.rs
index dcb7e56106..c376aeec9c 100644
--- a/mullvad-daemon/src/settings/mod.rs
+++ b/mullvad-daemon/src/settings/mod.rs
@@ -504,11 +504,11 @@ impl Display for SettingsSummary<'_> {
impl SettingsSummary<'_> {
fn fmt_option<T: Display>(f: &mut fmt::Formatter<'_>, val: Option<T>) -> fmt::Result {
- if let Some(inner) = &val {
+ match &val { Some(inner) => {
inner.fmt(f)
- } else {
+ } _ => {
f.write_str("unset")
- }
+ }}
}
}
diff --git a/mullvad-daemon/src/settings/patch.rs b/mullvad-daemon/src/settings/patch.rs
index 6e66fe6389..840117941d 100644
--- a/mullvad-daemon/src/settings/patch.rs
+++ b/mullvad-daemon/src/settings/patch.rs
@@ -238,7 +238,7 @@ fn merge_relay_overrides(
// Replace or append to existing values
match (existing_val, patch_override) {
(
- serde_json::Value::Object(ref mut current),
+ &mut serde_json::Value::Object(ref mut current),
serde_json::Value::Object(ref patch),
) => {
for (k, v) in patch {
@@ -274,9 +274,9 @@ fn merge_patch_to_value(
match (&permitted_key.key_type, current_value, patch_value) {
// Append or replace keys to objects
(
- PermittedKeyValue::Object(sub_permitted),
- serde_json::Value::Object(ref mut current),
- serde_json::Value::Object(ref patch),
+ &PermittedKeyValue::Object(ref sub_permitted),
+ &mut serde_json::Value::Object(ref mut current),
+ &serde_json::Value::Object(ref patch),
) => {
for (k, sub_patch) in patch {
let Some((_, sub_permitted)) = sub_permitted
diff --git a/mullvad-daemon/src/version_check.rs b/mullvad-daemon/src/version_check.rs
index ed50eb6ff5..d59c0d09cf 100644
--- a/mullvad-daemon/src/version_check.rs
+++ b/mullvad-daemon/src/version_check.rs
@@ -252,7 +252,7 @@ impl VersionUpdaterInner {
/// Wait until [Self::last_app_version_info] becomes stale and needs to be refreshed.
///
/// This happens [UPDATE_INTERVAL] after the last version check.
- fn wait_until_version_is_stale(&self) -> Pin<Box<impl FusedFuture<Output = ()>>> {
+ fn wait_until_version_is_stale(&self) -> Pin<Box<impl FusedFuture<Output = ()> + use<>>> {
let time_until_stale = self.time_until_version_is_stale();
// Boxed, pinned, and fused.
@@ -396,7 +396,7 @@ struct UpdateContext {
impl UpdateContext {
/// Write [VersionUpdaterInner::last_app_version_info], if any, to the cache file
/// ([VERSION_INFO_FILENAME]). Also, notify `self.update_sender`
- fn update(&self, last_app_version: AppVersionInfo) -> impl Future<Output = Result<(), Error>> {
+ fn update(&self, last_app_version: AppVersionInfo) -> impl Future<Output = Result<(), Error>> + use<> {
let _ = self.update_sender.send(last_app_version.clone());
let cache_path = self.cache_path.clone();