Skip to content

Commit 4f7204b

Browse files
committed
build.rs: use option_env! to register env variable dependency
Cargo automatically registers environment variable as dependency if `env!` or `option_env!` is used, while `std::env::var` would require a manual `cargo:rerun-if-env-changed` print. Thus switch to use the macro. Signed-off-by: Gary Guo <gary@garyguo.net>
1 parent 0ce5e88 commit 4f7204b

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn main() {
66

77
let meta = version_meta().unwrap();
88

9-
let use_feature = meta.channel == Channel::Nightly || std::env::var("RUSTC_BOOTSTRAP").is_ok();
9+
let use_feature = meta.channel == Channel::Nightly || option_env!("RUSTC_BOOTSTRAP").is_some();
1010
if use_feature {
1111
// Use this cfg option to control whether we should enable features that are already stable
1212
// in some new Rust versions, but are available as unstable features in older Rust versions

internal/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ fn main() {
55

66
let meta = version_meta().unwrap();
77

8-
let use_feature = meta.channel == Channel::Nightly || std::env::var("RUSTC_BOOTSTRAP").is_ok();
8+
let use_feature = meta.channel == Channel::Nightly || option_env!("RUSTC_BOOTSTRAP").is_some();
99
if use_feature {
1010
println!("cargo:rustc-cfg=USE_RUSTC_FEATURES");
1111
}

0 commit comments

Comments
 (0)