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

15 files changed

Lines changed: 25 additions & 20 deletions

File tree

.changes/rustc-check-cfg.md

Lines changed: 9 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 7 deletions
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

0 commit comments

Comments
 (0)