Fix the Clippy findings in the Linux-only code paths

This commit is contained in:
Thorsten Sommer 2026-09-13 13:20:34 +02:00
parent 08b6a190a8
commit 9c3fcbf815
Signed by untrusted user who does not match committer: tsommer
GPG Key ID: 371BBA77A02C0108
3 changed files with 43 additions and 39 deletions

View File

@ -504,12 +504,12 @@ fn read_locale_from_environment() -> Option<(String, &'static str)> {
} }
for key in ["LC_ALL", "LC_MESSAGES", "LANG"] { for key in ["LC_ALL", "LC_MESSAGES", "LANG"] {
if let Ok(value) = env::var(key) { if let Ok(value) = env::var(key)
if let Some(locale) = normalize_locale_tag(&value) { && let Some(locale) = normalize_locale_tag(&value)
{
return Some((locale, key)); return Some((locale, key));
} }
} }
}
None None
} }

View File

@ -149,6 +149,12 @@ struct ShortcutManager {
/// Stores the backend-specific resources required by an active shortcut. /// Stores the backend-specific resources required by an active shortcut.
enum ActiveBinding { enum ActiveBinding {
/// Stores a shortcut registered through the Tauri plugin. /// Stores a shortcut registered through the Tauri plugin.
///
/// Never constructed on Linux: registration there goes through the XDG portal and falls back
/// to the focused window, so nothing ever reaches the Tauri plugin. The variant stays all the
/// same, because the code which releases, suspends, and restores bindings is shared across
/// platforms and would otherwise have to be cut in two for one unreachable case.
#[cfg_attr(target_os = "linux", allow(dead_code))]
Tauri { Tauri {
/// Contains the registered shortcut in Tauri syntax. /// Contains the registered shortcut in Tauri syntax.
shortcut: String, shortcut: String,
@ -247,13 +253,12 @@ pub async fn register(
} }
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
{
match prepare_portal_binding(&request, event_sender.clone()).await { match prepare_portal_binding(&request, event_sender.clone()).await {
Ok(new_binding) => { Ok(new_binding) => {
let effective_display_name = new_binding.effective_display_name(); let effective_display_name = new_binding.effective_display_name();
replace_portal_binding(&app_handle, &mut manager, request.id, new_binding).await; replace_portal_binding(&app_handle, &mut manager, request.id, new_binding).await;
info!(Source = "XDG portal"; "Global shortcut '{}' is active through the desktop portal.", request.id); info!(Source = "XDG portal"; "Global shortcut '{}' is active through the desktop portal.", request.id);
return ShortcutResponse::success(ShortcutBackend::Portal, effective_display_name); ShortcutResponse::success(ShortcutBackend::Portal, effective_display_name)
}, },
Err(error) => { Err(error) => {
@ -266,7 +271,7 @@ pub async fn register(
} }
manager.bindings.insert(request.id, ActiveBinding::Local { shortcut: request.shortcut.clone() }); manager.bindings.insert(request.id, ActiveBinding::Local { shortcut: request.shortcut.clone() });
return ShortcutResponse::success(ShortcutBackend::Local, request.shortcut); ShortcutResponse::success(ShortcutBackend::Local, request.shortcut)
} else { } else {
let cancelled = error.kind == PortalFailureKind::Cancelled; let cancelled = error.kind == PortalFailureKind::Cancelled;
if cancelled { if cancelled {
@ -277,11 +282,10 @@ pub async fn register(
error!(Source = "XDG portal"; "Global shortcut registration failed; preserving the active portal binding: {}", error.message); error!(Source = "XDG portal"; "Global shortcut registration failed; preserving the active portal binding: {}", error.message);
} }
return ShortcutResponse::error(error.message, ShortcutBackend::Portal, cancelled); ShortcutResponse::error(error.message, ShortcutBackend::Portal, cancelled)
} }
}, },
} }
}
#[cfg(not(target_os = "linux"))] #[cfg(not(target_os = "linux"))]
match register_tauri_binding(&app_handle, &request.shortcut, request.id, event_sender) { match register_tauri_binding(&app_handle, &request.shortcut, request.id, event_sender) {

View File

@ -23,11 +23,11 @@ fn issue_code(error: &KeyringError) -> SecretStoreIssueCode {
} }
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
if let KeyringError::PlatformFailure(error) | KeyringError::NoStorageAccess(error) = error { if let KeyringError::PlatformFailure(error) | KeyringError::NoStorageAccess(error) = error
if let Some(error) = error.downcast_ref::<dbus_secret_service::Error>() { && let Some(error) = error.downcast_ref::<dbus_secret_service::Error>()
{
return secret_service_issue_code(error); return secret_service_issue_code(error);
} }
}
SecretStoreIssueCode::Unknown SecretStoreIssueCode::Unknown
} }