You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/doc/unstable-book/src/compiler-flags/env.md
+19-1
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,10 @@ The tracking issue for this feature is: [#118372](https://github.com/rust-lang/r
5
5
------------------------
6
6
7
7
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.
10
+
11
+
This information will be stored in the dep-info files.
9
12
10
13
When retrieving an environment variable value, the one specified by `--env` will take
11
14
precedence. For example, if you want have `PATH=a` in your environment and pass:
@@ -20,6 +23,21 @@ Then you will have:
20
23
assert_eq!(env!("PATH"), "env");
21
24
```
22
25
26
+
It will trigger a new compilation if any of the `--env` argument value is different.
27
+
So if you first passed:
28
+
29
+
```bash
30
+
--env A=B --env X=12
31
+
```
32
+
33
+
and then on next compilation:
34
+
35
+
```bash
36
+
--env A=B
37
+
```
38
+
39
+
`X` value is different (not set) so the code will be re-compiled.
40
+
23
41
Please note that on Windows, environment variables are case insensitive but case
24
42
preserving whereas `rustc`'s environment variables are case sensitive. For example,
25
43
having `Path` in your environment (case insensitive) is different than using
0 commit comments