Skip to content

Commit

Permalink
Extern crate proc_macro available on all wasm targets
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed May 25, 2023
1 parent d51f395 commit e60c466
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions build.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
}

Expand All @@ -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,
Expand Down

0 comments on commit e60c466

Please sign in to comment.