From 8b3b60812d9f561cb7f59120993fbf2e23191e2b Mon Sep 17 00:00:00 2001 From: Mingwei Samuel Date: Tue, 14 Jan 2025 15:58:48 -0800 Subject: [PATCH] style: fix all unexpected cfgs (#1648) Testing in https://github.com/MingweiSamuel/hydroflow https://github.com/MingweiSamuel/hydroflow/actions/runs/12777967961/job/35619880542 --- Cargo.lock | 57 +++++++++++-------- dfir_rs/tests/surface_examples.rs | 6 +- hydro_deploy/core/src/deployment.rs | 5 ++ .../src/hydroflow_crate/tracing_options.rs | 4 ++ multiplatform_test/src/lib.rs | 4 +- stageleft/src/lib.rs | 6 +- stageleft_tool/src/lib.rs | 14 +++-- 7 files changed, 58 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 48c2affc962a..810ee9086979 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1893,10 +1893,11 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -3114,6 +3115,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustversion" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" + [[package]] name = "ryu" version = "1.0.18" @@ -4245,24 +4252,24 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", "syn 2.0.75", @@ -4271,21 +4278,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.43" +version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ "cfg-if", "js-sys", + "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4293,9 +4301,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", @@ -4306,20 +4314,21 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "wasm-bindgen-test" -version = "0.3.43" +version = "0.3.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68497a05fb21143a08a7d24fc81763384a3072ee43c44e86aad1744d6adef9d9" +checksum = "66c8d5e33ca3b6d9fa3b4676d774c5778031d27a578c2b007f905acf816152c3" dependencies = [ - "console_error_panic_hook", "js-sys", "minicov", - "scoped-tls", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-test-macro", @@ -4327,9 +4336,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.43" +version = "0.3.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8220be1fa9e4c889b30fd207d4906657e7e90b12e0e6b0c8b8d8709f5de021" +checksum = "17d5042cc5fa009658f9a7333ef24291b1291a25b6382dd68862a7f3b969f69b" dependencies = [ "proc-macro2", "quote", @@ -4338,9 +4347,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", @@ -4417,7 +4426,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.48.0", ] [[package]] diff --git a/dfir_rs/tests/surface_examples.rs b/dfir_rs/tests/surface_examples.rs index 36acb582b6c6..15d7ac777e92 100644 --- a/dfir_rs/tests/surface_examples.rs +++ b/dfir_rs/tests/surface_examples.rs @@ -11,11 +11,7 @@ fn test_all() { let examples_files = read_dir("examples/") .unwrap() .flat_map(Result::ok) - .filter(|entry| { - entry - .file_type() - .map_or(false, |file_type| file_type.is_file()) - }) + .filter(|entry| entry.file_type().is_ok_and(|file_type| file_type.is_file())) .map(|entry| entry.file_name()) .map(|filename| filename.into_string().unwrap()) .filter(|filename| filename.starts_with("example_") && filename.ends_with(".rs")) diff --git a/hydro_deploy/core/src/deployment.rs b/hydro_deploy/core/src/deployment.rs index bcec6996e3d5..f2608108bd56 100644 --- a/hydro_deploy/core/src/deployment.rs +++ b/hydro_deploy/core/src/deployment.rs @@ -1,3 +1,8 @@ +#![allow( + unexpected_cfgs, + reason = "https://github.com/BrynCooke/buildstructor/issues/192" +)] + use std::collections::HashMap; use std::future::Future; use std::sync::{Arc, Weak}; diff --git a/hydro_deploy/core/src/hydroflow_crate/tracing_options.rs b/hydro_deploy/core/src/hydroflow_crate/tracing_options.rs index 096ae9da0ff0..522831a79f76 100644 --- a/hydro_deploy/core/src/hydroflow_crate/tracing_options.rs +++ b/hydro_deploy/core/src/hydroflow_crate/tracing_options.rs @@ -1,4 +1,8 @@ #![allow(clippy::too_many_arguments, reason = "buildstructor")] +#![allow( + unexpected_cfgs, + reason = "https://github.com/BrynCooke/buildstructor/issues/192" +)] use std::path::PathBuf; diff --git a/multiplatform_test/src/lib.rs b/multiplatform_test/src/lib.rs index a1826fc960a3..88021fb8b7cd 100644 --- a/multiplatform_test/src/lib.rs +++ b/multiplatform_test/src/lib.rs @@ -51,9 +51,7 @@ impl Platform { Platform::Tokio => quote! { #[tokio::test ] }, Platform::AsyncStd => quote! { #[async_std::test] }, Platform::Dfir => quote! { #[dfir_rs::test] }, - Platform::Wasm => { - quote! { #[wasm_bindgen_test::wasm_bindgen_test] } - } + Platform::Wasm => quote! { #[wasm_bindgen_test::wasm_bindgen_test] }, Platform::EnvLogging | Platform::EnvTracing => Default::default(), } } diff --git a/stageleft/src/lib.rs b/stageleft/src/lib.rs index b8c662be384e..7de48bef0409 100644 --- a/stageleft/src/lib.rs +++ b/stageleft/src/lib.rs @@ -54,16 +54,17 @@ macro_rules! stageleft_crate { "lib_macro.rs" )); - #[cfg(not(feature = "stageleft_devel"))] #[cfg(not(stageleft_macro))] #[doc(hidden)] #[allow( unused, ambiguous_glob_reexports, + unexpected_cfgs, clippy::suspicious_else_formatting, reason = "generated code" )] pub mod __staged { + #[cfg(not(feature = "stageleft_devel"))] include!(concat!( env!("OUT_DIR"), $crate::PATH_SEPARATOR!(), @@ -76,16 +77,17 @@ macro_rules! stageleft_crate { #[macro_export] macro_rules! stageleft_no_entry_crate { () => { - #[cfg(not(feature = "stageleft_devel"))] #[doc(hidden)] #[allow( unused, ambiguous_glob_reexports, + unexpected_cfgs, clippy::suspicious_else_formatting, clippy::type_complexity, reason = "generated code" )] pub mod __staged { + #[cfg(not(feature = "stageleft_devel"))] include!(concat!( env!("OUT_DIR"), $crate::PATH_SEPARATOR!(), diff --git a/stageleft_tool/src/lib.rs b/stageleft_tool/src/lib.rs index 5e6d486e9ef1..2d2dd15fbc76 100644 --- a/stageleft_tool/src/lib.rs +++ b/stageleft_tool/src/lib.rs @@ -321,7 +321,6 @@ pub fn gen_final_helper() { ) .unwrap(); - println!("cargo::rustc-check-cfg=cfg(stageleft_macro)"); println!("cargo::rerun-if-changed=build.rs"); println!("cargo::rerun-if-changed=src"); } @@ -329,8 +328,15 @@ pub fn gen_final_helper() { #[macro_export] macro_rules! gen_final { () => { - #[allow(unexpected_cfgs)] - #[cfg(not(feature = "stageleft_devel"))] - $crate::gen_final_helper() + #[allow( + unexpected_cfgs, + reason = "Consumer crates may optionally add the `stageleft_devel` feature." + )] + { + println!("cargo::rustc-check-cfg=cfg(stageleft_macro)"); + + #[cfg(not(feature = "stageleft_devel"))] + $crate::gen_final_helper() + } }; }