From e60c4662905a44740ca217c256cc9ab91a59f025 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 25 May 2023 14:12:51 -0700 Subject: [PATCH] Extern crate proc_macro available on all wasm targets --- build.rs | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/build.rs b/build.rs index 6173e7e4..d7b4b923 100644 --- a/build.rs +++ b/build.rs @@ -1,10 +1,8 @@ // rustc-cfg emitted by the build script: // // "use_proc_macro" -// Link to extern crate proc_macro. Available on any compiler and any target -// except wasm32. Requires "proc-macro" Cargo cfg to be enabled (default is -// enabled). On wasm32 we never link to proc_macro even if "proc-macro" cfg -// is enabled. +// Link to extern crate proc_macro. Requires "proc-macro" Cargo cfg to be +// enabled (default is enabled). // // "wrap_proc_macro" // Wrap types from libproc_macro rather than polyfilling the whole API. @@ -109,8 +107,7 @@ fn main() { println!("cargo:rustc-cfg=no_source_text"); } - let target = env::var("TARGET").unwrap(); - if !enable_use_proc_macro(&target) { + if !cfg!(feature = "proc-macro") { return; } @@ -132,16 +129,6 @@ fn main() { } } -fn enable_use_proc_macro(target: &str) -> bool { - // wasm targets don't have the `proc_macro` crate, disable this feature. - if target.contains("wasm32") && target != "wasm32-unknown-emscripten" { - return false; - } - - // Otherwise, only enable it if our feature is actually enabled. - cfg!(feature = "proc-macro") -} - struct RustcVersion { minor: u32, nightly: bool,