diff --git a/.changes/rustc-check-cfg.md b/.changes/rustc-check-cfg.md new file mode 100644 index 000000000..6bb9a2bce --- /dev/null +++ b/.changes/rustc-check-cfg.md @@ -0,0 +1,9 @@ +--- +"tauri": patch:changes +"tauri-build": patch:changes +"tauri-runtime": patch:changes +"tauri-runtime-wry": patch:changes +"tauri-plugin": patch:changes +--- + +Emit `cargo:rustc-check-cfg` instruction so Cargo validates custom cfg attributes on Rust 1.80 (or nightly-2024-05-05). diff --git a/core/tauri-build/src/lib.rs b/core/tauri-build/src/lib.rs index a31bf6791..fc90d2b7e 100644 --- a/core/tauri-build/src/lib.rs +++ b/core/tauri-build/src/lib.rs @@ -211,6 +211,7 @@ fn copy_frameworks(dest_dir: &Path, frameworks: &[String]) -> Result<()> { // creates a cfg alias if `has_feature` is true. // `alias` must be a snake case string. fn cfg_alias(alias: &str, has_feature: bool) { + println!("cargo:rustc-check-cfg=cfg({alias})"); if has_feature { println!("cargo:rustc-cfg={alias}"); } diff --git a/core/tauri-plugin/src/build/mod.rs b/core/tauri-plugin/src/build/mod.rs index 8587c894f..ab5a2c450 100644 --- a/core/tauri-plugin/src/build/mod.rs +++ b/core/tauri-plugin/src/build/mod.rs @@ -139,6 +139,7 @@ impl<'a> Builder<'a> { } fn cfg_alias(alias: &str, has_feature: bool) { + println!("cargo:rustc-check-cfg=cfg({alias})"); if has_feature { println!("cargo:rustc-cfg={alias}"); } diff --git a/core/tauri-runtime-wry/build.rs b/core/tauri-runtime-wry/build.rs index 57f522ab6..9974c5040 100644 --- a/core/tauri-runtime-wry/build.rs +++ b/core/tauri-runtime-wry/build.rs @@ -5,6 +5,7 @@ // creates a cfg alias if `has_feature` is true. // `alias` must be a snake case string. fn alias(alias: &str, has_feature: bool) { + println!("cargo:rustc-check-cfg=cfg({alias})"); if has_feature { println!("cargo:rustc-cfg={alias}"); } diff --git a/core/tauri-runtime-wry/src/lib.rs b/core/tauri-runtime-wry/src/lib.rs index ed2c7f1aa..a1fb442dc 100644 --- a/core/tauri-runtime-wry/src/lib.rs +++ b/core/tauri-runtime-wry/src/lib.rs @@ -3394,7 +3394,7 @@ fn handle_event_loop( } } TaoWindowEvent::CloseRequested => { - on_close_requested(callback, window_id, windows.clone()); + on_close_requested(callback, window_id, windows); } TaoWindowEvent::Destroyed => { let removed = windows.0.borrow_mut().remove(&window_id).is_some(); @@ -3455,10 +3455,10 @@ fn handle_event_loop( } } Message::Window(id, WindowMessage::Close) => { - on_close_requested(callback, id, windows.clone()); + on_close_requested(callback, id, windows); } Message::Window(id, WindowMessage::Destroy) => { - on_window_close(id, windows.clone()); + on_window_close(id, windows); } Message::UserEvent(t) => callback(RunEvent::UserEvent(t)), message => { diff --git a/core/tauri-runtime/build.rs b/core/tauri-runtime/build.rs index 57f522ab6..9974c5040 100644 --- a/core/tauri-runtime/build.rs +++ b/core/tauri-runtime/build.rs @@ -5,6 +5,7 @@ // creates a cfg alias if `has_feature` is true. // `alias` must be a snake case string. fn alias(alias: &str, has_feature: bool) { + println!("cargo:rustc-check-cfg=cfg({alias})"); if has_feature { println!("cargo:rustc-cfg={alias}"); } diff --git a/core/tauri/build.rs b/core/tauri/build.rs index 39142c3f4..9b1dfc5af 100644 --- a/core/tauri/build.rs +++ b/core/tauri/build.rs @@ -215,6 +215,7 @@ fn has_feature(feature: &str) -> bool { // creates a cfg alias if `has_feature` is true. // `alias` must be a snake case string. fn alias(alias: &str, has_feature: bool) { + println!("cargo:rustc-check-cfg=cfg({alias})"); if has_feature { println!("cargo:rustc-cfg={alias}"); } diff --git a/core/tauri/src/app.rs b/core/tauri/src/app.rs index 049885558..fa8cd95dc 100644 --- a/core/tauri/src/app.rs +++ b/core/tauri/src/app.rs @@ -329,7 +329,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>) -> Result { - Ok(command.message.webview().window().app_handle.clone()) + Ok(command.message.webview().window().app_handle) } } diff --git a/core/tauri/src/event/listener.rs b/core/tauri/src/event/listener.rs index 26e10d312..a02c2df86 100644 --- a/core/tauri/src/event/listener.rs +++ b/core/tauri/src/event/listener.rs @@ -197,7 +197,7 @@ impl Listeners { let mut maybe_pending = false; match self.inner.handlers.try_lock() { - Err(_) => self.insert_pending(Pending::Emit(emit_args.clone())), + Err(_) => self.insert_pending(Pending::Emit(emit_args)), Ok(lock) => { if let Some(handlers) = lock.get(&emit_args.event_name) { let handlers = handlers.iter(); diff --git a/core/tauri/src/lib.rs b/core/tauri/src/lib.rs index d507c8af6..24a7aceb9 100644 --- a/core/tauri/src/lib.rs +++ b/core/tauri/src/lib.rs @@ -518,13 +518,6 @@ impl Context { plugin_global_api_scripts, } } - - /// Sets the app shell scope. - #[cfg(shell_scope)] - #[inline(always)] - pub fn set_shell_scope(&mut self, scope: scope::ShellScopeConfig) { - self.shell_scope = scope; - } } // TODO: expand these docs diff --git a/core/tauri/src/manager/webview.rs b/core/tauri/src/manager/webview.rs index 5f138c0f6..deb295831 100644 --- a/core/tauri/src/manager/webview.rs +++ b/core/tauri/src/manager/webview.rs @@ -279,8 +279,7 @@ impl WebviewManager { } if !registered_scheme_protocols.contains(&"ipc".into()) { - let protocol = - crate::ipc::protocol::get(manager.manager_owned().clone(), pending.label.clone()); + let protocol = crate::ipc::protocol::get(manager.manager_owned(), pending.label.clone()); pending.register_uri_scheme_protocol("ipc", move |request, responder| { protocol(request, UriSchemeResponder(responder)) }); @@ -619,7 +618,7 @@ impl WebviewManager { } // let plugins know that a new webview has been added to the manager - let manager = webview.manager_owned().clone(); + let manager = webview.manager_owned(); let webview_ = webview.clone(); // run on main thread so the plugin store doesn't dead lock with the event loop handler in App let _ = webview.run_on_main_thread(move || { diff --git a/core/tauri/src/protocol/tauri.rs b/core/tauri/src/protocol/tauri.rs index 3b713e0b8..dc025805f 100644 --- a/core/tauri/src/protocol/tauri.rs +++ b/core/tauri/src/protocol/tauri.rs @@ -37,7 +37,6 @@ pub fn get( url }; - let manager = manager.clone(); let window_origin = window_origin.to_string(); #[cfg(all(dev, mobile))] diff --git a/core/tauri/src/scope/fs.rs b/core/tauri/src/scope/fs.rs index 11af889c2..35930a5a0 100644 --- a/core/tauri/src/scope/fs.rs +++ b/core/tauri/src/scope/fs.rs @@ -307,7 +307,7 @@ impl Scope { path.to_path_buf() }; let path = if !path.exists() { - crate::Result::Ok(path.to_path_buf()) + crate::Result::Ok(path) } else { std::fs::canonicalize(path).map_err(Into::into) }; diff --git a/core/tauri/src/webview/webview_window.rs b/core/tauri/src/webview/webview_window.rs index 69547bcc1..e96c73b24 100644 --- a/core/tauri/src/webview/webview_window.rs +++ b/core/tauri/src/webview/webview_window.rs @@ -1044,7 +1044,7 @@ tauri::Builder::default() menu: &M, position: P, ) -> crate::Result<()> { - menu.popup_at(self.webview.window().clone(), position) + menu.popup_at(self.webview.window(), position) } } diff --git a/core/tauri/src/window/mod.rs b/core/tauri/src/window/mod.rs index ce7ae2761..47fdfa76b 100644 --- a/core/tauri/src/window/mod.rs +++ b/core/tauri/src/window/mod.rs @@ -240,7 +240,7 @@ async fn reopen_window(app: tauri::AppHandle) { /// /// [the Webview2 issue]: https://github.com/tauri-apps/wry/issues/583 pub fn from_config(manager: &'a M, config: &WindowConfig) -> crate::Result { - #[cfg_attr(not(unstable), allow(unused_mut))] + #[cfg_attr(not(windows), allow(unused_mut))] let mut builder = Self { manager, label: config.label.clone(), @@ -968,7 +968,7 @@ impl ManagerBase for Window { impl<'de, R: Runtime> CommandArg<'de, R> for Window { /// Grabs the [`Window`] from the [`CommandItem`]. This will never fail. fn from_command(command: CommandItem<'de, R>) -> Result { - Ok(command.message.webview().window().clone()) + Ok(command.message.webview().window()) } }