Open
Description
Adds a new --env-set
command line option on rustc. It allows to set environment variables value at compile-time to be used by env!
and option_env!
macros.
When retrieving and environment variable value, the one specified by --env-set
will take precedence. For example if you want have PATH=a
in your environment and pass --env-set PATH=env
, then you will have:
assert_eq!(env!("PATH"), "env");
Steps
- Implement the MCP -> Done in Implement
--env
compiler flag (withouttracked_env
support) #118368, in Add support for--env
ontracked_env::var
#118830 and in Rename--env
option flag to--env-set
#119884 - Stabilization PR - Stabilize
--env-set
option #119926
Unresolved questions
- What is the desired behavior if the same
--env
variable is passed twice?