Skip to content

Commit

Permalink
chore: emit rustc-check-cfg for rust 1.80 (#10392)
Browse files Browse the repository at this point in the history
* chore: emit rustc-check-cfg for rust 1.80

* build: add lints.rust.unexpected_cfgs to suppress false positive warnings
  • Loading branch information
anatawa12 authored Jul 29, 2024
1 parent 51d0432 commit fbcbc5e
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .changes/rustc-check-cfg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"tauri": patch:changes
"tauri-build": patch:changes
"tauri-runtime": patch:changes
"tauri-runtime-wry": patch:changes
---

Emit `cargo:rustc-check-cfg` instruction so Cargo validates custom cfg attributes on Rust 1.80 (or nightly-2024-05-05).
4 changes: 4 additions & 0 deletions core/tauri-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ readme = "README.md"
all-features = true
rustdoc-args = [ "--cfg", "doc_cfg" ]

[lints.rust]
# cfg(doc_cfg) is used for docs.rs detection. see above
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(doc_cfg)'] }

[dependencies]
anyhow = "1"
quote = { version = "1", optional = true }
Expand Down
1 change: 1 addition & 0 deletions core/tauri-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ fn has_feature(feature: &str) -> bool {
// 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}");
}
Expand Down
1 change: 1 addition & 0 deletions core/tauri-runtime-wry/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}
Expand Down
4 changes: 4 additions & 0 deletions core/tauri-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ targets = [
"x86_64-apple-darwin"
]

[lints.rust]
# cfg(doc_cfg) is used for docs.rs detection. see above
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(doc_cfg)'] }

[dependencies]
serde = { version = "1.0", features = [ "derive" ] }
serde_json = "1.0"
Expand Down
1 change: 1 addition & 0 deletions core/tauri-runtime/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}
Expand Down
4 changes: 4 additions & 0 deletions core/tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ targets = [
"x86_64-apple-darwin"
]

[lints.rust]
# cfg(doc_cfg) is used for docs.rs detection. see above
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(doc_cfg)'] }

[package.metadata.cargo-udeps.ignore]
normal = [ "reqwest", "nix" ]

Expand Down
1 change: 1 addition & 0 deletions core/tauri/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,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}");
}
Expand Down

0 comments on commit fbcbc5e

Please sign in to comment.