From 4f7204b32a2d3db5f9f993aa300e74e1ee4344e0 Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Sat, 4 Apr 2026 14:57:57 +0100 Subject: [PATCH] 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 --- build.rs | 2 +- internal/build.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index 6465fcc0..17305e0b 100644 --- a/build.rs +++ b/build.rs @@ -6,7 +6,7 @@ fn main() { let meta = version_meta().unwrap(); - let use_feature = meta.channel == Channel::Nightly || std::env::var("RUSTC_BOOTSTRAP").is_ok(); + let use_feature = meta.channel == Channel::Nightly || option_env!("RUSTC_BOOTSTRAP").is_some(); if use_feature { // Use this cfg option to control whether we should enable features that are already stable // in some new Rust versions, but are available as unstable features in older Rust versions diff --git a/internal/build.rs b/internal/build.rs index b8faf9f6..68566c99 100644 --- a/internal/build.rs +++ b/internal/build.rs @@ -5,7 +5,7 @@ fn main() { let meta = version_meta().unwrap(); - let use_feature = meta.channel == Channel::Nightly || std::env::var("RUSTC_BOOTSTRAP").is_ok(); + let use_feature = meta.channel == Channel::Nightly || option_env!("RUSTC_BOOTSTRAP").is_some(); if use_feature { println!("cargo:rustc-cfg=USE_RUSTC_FEATURES"); }