From 447bdc35776ea90e0ba8fda06bf61a67e517411f Mon Sep 17 00:00:00 2001 From: c Date: Thu, 18 Dec 2025 11:09:20 +0100 Subject: [PATCH 1/3] refactor(tauri): do not need explicit naming --- crates/tauri/src/app.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/tauri/src/app.rs b/crates/tauri/src/app.rs index e53f22675245..59ae72028a48 100644 --- a/crates/tauri/src/app.rs +++ b/crates/tauri/src/app.rs @@ -64,7 +64,7 @@ pub(crate) type GlobalWebviewEventListener = Box, &WebviewEvent) + Send + Sync>; /// A closure that is run when the Tauri application is setting up. pub type SetupHook = - Box) -> std::result::Result<(), Box> + Send>; + Box) -> Result<(), Box> + Send>; /// A closure that is run every time a page starts or finishes loading. pub type OnPageLoad = dyn Fn(&Webview, &PageLoadPayload<'_>) + Send + Sync + 'static; pub type ChannelInterceptor = @@ -443,7 +443,7 @@ impl Clone for AppHandle { impl<'de, R: Runtime> CommandArg<'de, R> for AppHandle { /// Grabs the [`Window`] from the [`CommandItem`] and returns the associated [`AppHandle`]. This will never fail. - fn from_command(command: CommandItem<'de, R>) -> std::result::Result { + fn from_command(command: CommandItem<'de, R>) -> Result { Ok(command.message.webview().app_handle) } } @@ -1640,7 +1640,7 @@ tauri::Builder::default() #[must_use] pub fn setup(mut self, setup: F) -> Self where - F: FnOnce(&mut App) -> std::result::Result<(), Box> + Send + 'static, + F: FnOnce(&mut App) -> Result<(), Box> + Send + 'static, { self.setup = Box::new(setup); self @@ -2353,7 +2353,7 @@ fn init_app_menu(menu: &Menu) -> crate::Result<()> { impl HasDisplayHandle for AppHandle { fn display_handle( &self, - ) -> std::result::Result, raw_window_handle::HandleError> { + ) -> Result, raw_window_handle::HandleError> { self.runtime_handle.display_handle() } } @@ -2361,7 +2361,7 @@ impl HasDisplayHandle for AppHandle { impl HasDisplayHandle for App { fn display_handle( &self, - ) -> std::result::Result, raw_window_handle::HandleError> { + ) -> Result, raw_window_handle::HandleError> { self.handle.display_handle() } } From d7c8a45e65616982f26fddb8be01ac1acefe03b4 Mon Sep 17 00:00:00 2001 From: c Date: Thu, 18 Dec 2025 11:11:36 +0100 Subject: [PATCH 2/3] breaking(tauri): breaking change, fix unsound Send, Sync --- crates/tauri/src/app.rs | 4 ++-- crates/tauri/src/error.rs | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/crates/tauri/src/app.rs b/crates/tauri/src/app.rs index 59ae72028a48..ecdc930663b7 100644 --- a/crates/tauri/src/app.rs +++ b/crates/tauri/src/app.rs @@ -64,7 +64,7 @@ pub(crate) type GlobalWebviewEventListener = Box, &WebviewEvent) + Send + Sync>; /// A closure that is run when the Tauri application is setting up. pub type SetupHook = - Box) -> Result<(), Box> + Send>; + Box) -> Result<(), Box> + Send>; /// A closure that is run every time a page starts or finishes loading. pub type OnPageLoad = dyn Fn(&Webview, &PageLoadPayload<'_>) + Send + Sync + 'static; pub type ChannelInterceptor = @@ -1640,7 +1640,7 @@ tauri::Builder::default() #[must_use] pub fn setup(mut self, setup: F) -> Self where - F: FnOnce(&mut App) -> Result<(), Box> + Send + 'static, + F: FnOnce(&mut App) -> Result<(), Box> + Send + 'static, { self.setup = Box::new(setup); self diff --git a/crates/tauri/src/error.rs b/crates/tauri/src/error.rs index 405a9b48dd1e..297025ef0f4e 100644 --- a/crates/tauri/src/error.rs +++ b/crates/tauri/src/error.rs @@ -6,19 +6,14 @@ use std::fmt; /// A generic boxed error. #[derive(Debug)] -pub struct SetupError(Box); +pub struct SetupError(Box); -impl From> for SetupError { - fn from(error: Box) -> Self { +impl From> for SetupError { + fn from(error: Box) -> Self { Self(error) } } -// safety: the setup error is only used on the main thread -// and we exit the process immediately. -unsafe impl Send for SetupError {} -unsafe impl Sync for SetupError {} - impl fmt::Display for SetupError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) From 1e8fca79d1d738464409a817c2d38c954954cd23 Mon Sep 17 00:00:00 2001 From: c Date: Fri, 19 Dec 2025 15:59:43 +0100 Subject: [PATCH 3/3] refactor(tauri-runtime-wry): remove unneeded auto trait impl --- crates/tauri-runtime-wry/src/lib.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/tauri-runtime-wry/src/lib.rs b/crates/tauri-runtime-wry/src/lib.rs index 61799d0394c9..f6e7fb7d8570 100644 --- a/crates/tauri-runtime-wry/src/lib.rs +++ b/crates/tauri-runtime-wry/src/lib.rs @@ -804,10 +804,6 @@ impl std::fmt::Debug for WindowBuilderWrapper { } } -// SAFETY: this type is `Send` since `menu_items` are read only here -#[allow(clippy::non_send_fields_in_send_ty)] -unsafe impl Send for WindowBuilderWrapper {} - impl WindowBuilderBase for WindowBuilderWrapper {} impl WindowBuilder for WindowBuilderWrapper { fn new() -> Self { @@ -5226,3 +5222,12 @@ fn to_tao_theme(theme: Option) -> Option { _ => None, } } + +#[cfg(test)] +mod tests { + fn is_send() {} + #[test] + fn are_send() { + is_send::(); + } +}