Skip to content

Commit 9ac9303

Browse files
chore: emit rustc-check-cfg for nightly (#9850)
* fix: emit cargo cfg alias using new syntax too * Update lib.rs * fixes for other crates * clippy * readd clone --------- Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
1 parent fd2d7cf commit 9ac9303

File tree

15 files changed

+25
-20
lines changed

15 files changed

+25
-20
lines changed

.changes/rustc-check-cfg.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"tauri": patch:changes
3+
"tauri-build": patch:changes
4+
"tauri-runtime": patch:changes
5+
"tauri-runtime-wry": patch:changes
6+
"tauri-plugin": patch:changes
7+
---
8+
9+
Emit `cargo:rustc-check-cfg` instruction so Cargo validates custom cfg attributes on Rust 1.80 (or nightly-2024-05-05).

core/tauri-build/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ fn copy_frameworks(dest_dir: &Path, frameworks: &[String]) -> Result<()> {
211211
// creates a cfg alias if `has_feature` is true.
212212
// `alias` must be a snake case string.
213213
fn cfg_alias(alias: &str, has_feature: bool) {
214+
println!("cargo:rustc-check-cfg=cfg({alias})");
214215
if has_feature {
215216
println!("cargo:rustc-cfg={alias}");
216217
}

core/tauri-plugin/src/build/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ impl<'a> Builder<'a> {
139139
}
140140

141141
fn cfg_alias(alias: &str, has_feature: bool) {
142+
println!("cargo:rustc-check-cfg=cfg({alias})");
142143
if has_feature {
143144
println!("cargo:rustc-cfg={alias}");
144145
}

core/tauri-runtime-wry/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// creates a cfg alias if `has_feature` is true.
66
// `alias` must be a snake case string.
77
fn alias(alias: &str, has_feature: bool) {
8+
println!("cargo:rustc-check-cfg=cfg({alias})");
89
if has_feature {
910
println!("cargo:rustc-cfg={alias}");
1011
}

core/tauri-runtime-wry/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3394,7 +3394,7 @@ fn handle_event_loop<T: UserEvent>(
33943394
}
33953395
}
33963396
TaoWindowEvent::CloseRequested => {
3397-
on_close_requested(callback, window_id, windows.clone());
3397+
on_close_requested(callback, window_id, windows);
33983398
}
33993399
TaoWindowEvent::Destroyed => {
34003400
let removed = windows.0.borrow_mut().remove(&window_id).is_some();
@@ -3455,10 +3455,10 @@ fn handle_event_loop<T: UserEvent>(
34553455
}
34563456
}
34573457
Message::Window(id, WindowMessage::Close) => {
3458-
on_close_requested(callback, id, windows.clone());
3458+
on_close_requested(callback, id, windows);
34593459
}
34603460
Message::Window(id, WindowMessage::Destroy) => {
3461-
on_window_close(id, windows.clone());
3461+
on_window_close(id, windows);
34623462
}
34633463
Message::UserEvent(t) => callback(RunEvent::UserEvent(t)),
34643464
message => {

core/tauri-runtime/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// creates a cfg alias if `has_feature` is true.
66
// `alias` must be a snake case string.
77
fn alias(alias: &str, has_feature: bool) {
8+
println!("cargo:rustc-check-cfg=cfg({alias})");
89
if has_feature {
910
println!("cargo:rustc-cfg={alias}");
1011
}

core/tauri/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ fn has_feature(feature: &str) -> bool {
215215
// creates a cfg alias if `has_feature` is true.
216216
// `alias` must be a snake case string.
217217
fn alias(alias: &str, has_feature: bool) {
218+
println!("cargo:rustc-check-cfg=cfg({alias})");
218219
if has_feature {
219220
println!("cargo:rustc-cfg={alias}");
220221
}

core/tauri/src/app.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ impl<R: Runtime> Clone for AppHandle<R> {
329329
impl<'de, R: Runtime> CommandArg<'de, R> for AppHandle<R> {
330330
/// Grabs the [`Window`] from the [`CommandItem`] and returns the associated [`AppHandle`]. This will never fail.
331331
fn from_command(command: CommandItem<'de, R>) -> Result<Self, InvokeError> {
332-
Ok(command.message.webview().window().app_handle.clone())
332+
Ok(command.message.webview().window().app_handle)
333333
}
334334
}
335335

core/tauri/src/event/listener.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl Listeners {
197197
let mut maybe_pending = false;
198198

199199
match self.inner.handlers.try_lock() {
200-
Err(_) => self.insert_pending(Pending::Emit(emit_args.clone())),
200+
Err(_) => self.insert_pending(Pending::Emit(emit_args)),
201201
Ok(lock) => {
202202
if let Some(handlers) = lock.get(&emit_args.event_name) {
203203
let handlers = handlers.iter();

core/tauri/src/lib.rs

-7
Original file line numberDiff line numberDiff line change
@@ -518,13 +518,6 @@ impl<R: Runtime> Context<R> {
518518
plugin_global_api_scripts,
519519
}
520520
}
521-
522-
/// Sets the app shell scope.
523-
#[cfg(shell_scope)]
524-
#[inline(always)]
525-
pub fn set_shell_scope(&mut self, scope: scope::ShellScopeConfig) {
526-
self.shell_scope = scope;
527-
}
528521
}
529522

530523
// TODO: expand these docs

core/tauri/src/manager/webview.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,7 @@ impl<R: Runtime> WebviewManager<R> {
279279
}
280280

281281
if !registered_scheme_protocols.contains(&"ipc".into()) {
282-
let protocol =
283-
crate::ipc::protocol::get(manager.manager_owned().clone(), pending.label.clone());
282+
let protocol = crate::ipc::protocol::get(manager.manager_owned(), pending.label.clone());
284283
pending.register_uri_scheme_protocol("ipc", move |request, responder| {
285284
protocol(request, UriSchemeResponder(responder))
286285
});
@@ -619,7 +618,7 @@ impl<R: Runtime> WebviewManager<R> {
619618
}
620619

621620
// let plugins know that a new webview has been added to the manager
622-
let manager = webview.manager_owned().clone();
621+
let manager = webview.manager_owned();
623622
let webview_ = webview.clone();
624623
// run on main thread so the plugin store doesn't dead lock with the event loop handler in App
625624
let _ = webview.run_on_main_thread(move || {

core/tauri/src/protocol/tauri.rs

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ pub fn get<R: Runtime>(
3737
url
3838
};
3939

40-
let manager = manager.clone();
4140
let window_origin = window_origin.to_string();
4241

4342
#[cfg(all(dev, mobile))]

core/tauri/src/scope/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ impl Scope {
307307
path.to_path_buf()
308308
};
309309
let path = if !path.exists() {
310-
crate::Result::Ok(path.to_path_buf())
310+
crate::Result::Ok(path)
311311
} else {
312312
std::fs::canonicalize(path).map_err(Into::into)
313313
};

core/tauri/src/webview/webview_window.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ tauri::Builder::default()
10441044
menu: &M,
10451045
position: P,
10461046
) -> crate::Result<()> {
1047-
menu.popup_at(self.webview.window().clone(), position)
1047+
menu.popup_at(self.webview.window(), position)
10481048
}
10491049
}
10501050

core/tauri/src/window/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ async fn reopen_window(app: tauri::AppHandle) {
240240
///
241241
/// [the Webview2 issue]: https://github.com/tauri-apps/wry/issues/583
242242
pub fn from_config(manager: &'a M, config: &WindowConfig) -> crate::Result<Self> {
243-
#[cfg_attr(not(unstable), allow(unused_mut))]
243+
#[cfg_attr(not(windows), allow(unused_mut))]
244244
let mut builder = Self {
245245
manager,
246246
label: config.label.clone(),
@@ -968,7 +968,7 @@ impl<R: Runtime> ManagerBase<R> for Window<R> {
968968
impl<'de, R: Runtime> CommandArg<'de, R> for Window<R> {
969969
/// Grabs the [`Window`] from the [`CommandItem`]. This will never fail.
970970
fn from_command(command: CommandItem<'de, R>) -> Result<Self, InvokeError> {
971-
Ok(command.message.webview().window().clone())
971+
Ok(command.message.webview().window())
972972
}
973973
}
974974

0 commit comments

Comments
 (0)