Skip to content

Commit eb4f224

Browse files
Update documentation for --env compilation flag
1 parent 32f5db9 commit eb4f224

File tree

1 file changed

+17
-1
lines changed
  • src/doc/unstable-book/src/compiler-flags

1 file changed

+17
-1
lines changed

src/doc/unstable-book/src/compiler-flags/env.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ The tracking issue for this feature is: [#118372](https://github.com/rust-lang/r
55
------------------------
66

77
This option flag allows to specify environment variables value at compile time to be
8-
used by `env!` and `option_env!` macros.
8+
used by `env!` and `option_env!` macros. It also impacts `tracked_env::var` function
9+
from the `proc_macro` crate.
910

1011
When retrieving an environment variable value, the one specified by `--env` will take
1112
precedence. For example, if you want have `PATH=a` in your environment and pass:
@@ -20,6 +21,21 @@ Then you will have:
2021
assert_eq!(env!("PATH"), "env");
2122
```
2223

24+
It will trigger a new compilation if any of the `--env` argument value is different.
25+
So if you first passed:
26+
27+
```bash
28+
--env A=B --env X=12
29+
```
30+
31+
and then on next compilation:
32+
33+
```bash
34+
--env A=B
35+
```
36+
37+
`X` value is different (not set) so the code will be re-compiled.
38+
2339
Please note that on Windows, environment variables are case insensitive but case
2440
preserving whereas `rustc`'s environment variables are case sensitive. For example,
2541
having `Path` in your environment (case insensitive) is different than using

0 commit comments

Comments
 (0)