From 706e4c8164543fbb72e674ffae2ab85488e8e9d2 Mon Sep 17 00:00:00 2001 From: Imbris <2002109+Imberflur@users.noreply.github.com> Date: Thu, 9 Jan 2025 16:40:33 -0500 Subject: [PATCH] Document that cargo automatically registers variables used in env! macro to trigger rebuilds --- src/doc/src/reference/build-scripts.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/doc/src/reference/build-scripts.md b/src/doc/src/reference/build-scripts.md index 7f4133d95bd..6a2a22ddecd 100644 --- a/src/doc/src/reference/build-scripts.md +++ b/src/doc/src/reference/build-scripts.md @@ -403,6 +403,13 @@ variables like `TARGET` that [Cargo sets for build scripts][build-env]. The environment variables in use are those received by `cargo` invocations, not those received by the executable of the build script. +As of 1.46, using [`env!`][env-macro] and [`option_env!`][option-env-macro] in +source code will automatically detect changes and trigger rebuilds. +`rerun-if-env-changed` is no longer needed for variables already referenced by +these macros. + +[option-env-macro]: ../../std/macro.option_env.html + ## The `links` Manifest Key The `package.links` key may be set in the `Cargo.toml` manifest to declare