Skip to content

Commit 482e71b

Browse files
committed
Fix triggering lints in testing facilities (rustwasm#4195)
1 parent 3a8da7c commit 482e71b

File tree

2 files changed

+45
-31
lines changed

2 files changed

+45
-31
lines changed

crates/test-macro/src/lib.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,15 @@ pub fn wasm_bindgen_test(
111111
let wasm_bindgen_path = attributes.wasm_bindgen_path;
112112
tokens.extend(
113113
quote! {
114-
#[no_mangle]
115-
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
116-
#[cfg_attr(wasm_bindgen_unstable_test_coverage, coverage(off))]
117-
pub extern "C" fn #name(cx: &#wasm_bindgen_path::__rt::Context) {
118-
let test_name = ::core::concat!(::core::module_path!(), "::", ::core::stringify!(#ident));
119-
#test_body
120-
}
114+
const _: () = {
115+
#[no_mangle]
116+
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
117+
#[cfg_attr(wasm_bindgen_unstable_test_coverage, coverage(off))]
118+
pub extern "C" fn #name(cx: &#wasm_bindgen_path::__rt::Context) {
119+
let test_name = ::core::concat!(::core::module_path!(), "::", ::core::stringify!(#ident));
120+
#test_body
121+
}
122+
};
121123
},
122124
);
123125

crates/test/src/lib.rs

+36-24
Original file line numberDiff line numberDiff line change
@@ -56,40 +56,52 @@ macro_rules! console_log {
5656
#[macro_export]
5757
macro_rules! wasm_bindgen_test_configure {
5858
(run_in_browser $($others:tt)*) => (
59-
#[link_section = "__wasm_bindgen_test_unstable"]
60-
#[cfg(target_arch = "wasm32")]
61-
pub static __WBG_TEST_RUN_IN_BROWSER: [u8; 1] = [0x01];
62-
$crate::wasm_bindgen_test_configure!($($others)*);
59+
const _: () = {
60+
#[link_section = "__wasm_bindgen_test_unstable"]
61+
#[cfg(target_arch = "wasm32")]
62+
pub static __WBG_TEST_RUN_IN_BROWSER: [u8; 1] = [0x01];
63+
$crate::wasm_bindgen_test_configure!($($others)*);
64+
};
6365
);
6466
(run_in_worker $($others:tt)*) => (
65-
#[link_section = "__wasm_bindgen_test_unstable"]
66-
#[cfg(target_arch = "wasm32")]
67-
pub static __WBG_TEST_RUN_IN_DEDICATED_WORKER: [u8; 1] = [0x02];
68-
$crate::wasm_bindgen_test_configure!($($others)*);
67+
const _: () = {
68+
#[link_section = "__wasm_bindgen_test_unstable"]
69+
#[cfg(target_arch = "wasm32")]
70+
pub static __WBG_TEST_RUN_IN_DEDICATED_WORKER: [u8; 1] = [0x02];
71+
$crate::wasm_bindgen_test_configure!($($others)*);
72+
};
6973
);
7074
(run_in_dedicated_worker $($others:tt)*) => (
71-
#[link_section = "__wasm_bindgen_test_unstable"]
72-
#[cfg(target_arch = "wasm32")]
73-
pub static __WBG_TEST_RUN_IN_DEDICATED_WORKER: [u8; 1] = [0x02];
74-
$crate::wasm_bindgen_test_configure!($($others)*);
75+
const _: () = {
76+
#[link_section = "__wasm_bindgen_test_unstable"]
77+
#[cfg(target_arch = "wasm32")]
78+
pub static __WBG_TEST_RUN_IN_DEDICATED_WORKER: [u8; 1] = [0x02];
79+
$crate::wasm_bindgen_test_configure!($($others)*);
80+
};
7581
);
7682
(run_in_shared_worker $($others:tt)*) => (
77-
#[link_section = "__wasm_bindgen_test_unstable"]
78-
#[cfg(target_arch = "wasm32")]
79-
pub static __WBG_TEST_RUN_IN_SHARED_WORKER: [u8; 1] = [0x03];
80-
$crate::wasm_bindgen_test_configure!($($others)*);
83+
const _: () = {
84+
#[link_section = "__wasm_bindgen_test_unstable"]
85+
#[cfg(target_arch = "wasm32")]
86+
pub static __WBG_TEST_RUN_IN_SHARED_WORKER: [u8; 1] = [0x03];
87+
$crate::wasm_bindgen_test_configure!($($others)*);
88+
};
8189
);
8290
(run_in_service_worker $($others:tt)*) => (
83-
#[link_section = "__wasm_bindgen_test_unstable"]
84-
#[cfg(target_arch = "wasm32")]
85-
pub static __WBG_TEST_RUN_IN_SERVICE_WORKER: [u8; 1] = [0x04];
86-
$crate::wasm_bindgen_test_configure!($($others)*);
91+
const _: () = {
92+
#[link_section = "__wasm_bindgen_test_unstable"]
93+
#[cfg(target_arch = "wasm32")]
94+
pub static __WBG_TEST_RUN_IN_SERVICE_WORKER: [u8; 1] = [0x04];
95+
$crate::wasm_bindgen_test_configure!($($others)*);
96+
};
8797
);
8898
(run_in_node_experimental $($others:tt)*) => (
89-
#[link_section = "__wasm_bindgen_test_unstable"]
90-
#[cfg(target_arch = "wasm32")]
91-
pub static __WBG_TEST_run_in_node_experimental: [u8; 1] = [0x05];
92-
$crate::wasm_bindgen_test_configure!($($others)*);
99+
const _: () = {
100+
#[link_section = "__wasm_bindgen_test_unstable"]
101+
#[cfg(target_arch = "wasm32")]
102+
pub static __WBG_TEST_run_in_node_experimental: [u8; 1] = [0x05];
103+
$crate::wasm_bindgen_test_configure!($($others)*);
104+
};
93105
);
94106
() => ()
95107
}

0 commit comments

Comments
 (0)