Skip to content

Commit 462bcac

Browse files
Rename --env option flag to --env-set
1 parent 2b1365b commit 462bcac

File tree

9 files changed

+17
-17
lines changed

9 files changed

+17
-17
lines changed

compiler/rustc_builtin_macros/src/env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn lookup_env<'cx>(cx: &'cx ExtCtxt<'_>, var: Symbol) -> Option<Symbol> {
1818
if let Some(value) = cx.sess.opts.logical_env.get(var) {
1919
return Some(Symbol::intern(value));
2020
}
21-
// If the environment variable was not defined with the `--env` option, we try to retrieve it
21+
// If the environment variable was not defined with the `--env-set` option, we try to retrieve it
2222
// from rustc's environment.
2323
env::var(var).ok().as_deref().map(Symbol::intern)
2424
}

compiler/rustc_session/src/config.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1823,7 +1823,7 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
18231823
"Remap source names in all output (compiler messages and output files)",
18241824
"FROM=TO",
18251825
),
1826-
opt::multi("", "env", "Inject an environment variable", "VAR=VALUE"),
1826+
opt::multi("", "env-set", "Inject an environment variable", "VAR=VALUE"),
18271827
]);
18281828
opts
18291829
}
@@ -2599,11 +2599,11 @@ fn parse_logical_env(
25992599
) -> FxIndexMap<String, String> {
26002600
let mut vars = FxIndexMap::default();
26012601

2602-
for arg in matches.opt_strs("env") {
2602+
for arg in matches.opt_strs("env-set") {
26032603
if let Some((name, val)) = arg.split_once('=') {
26042604
vars.insert(name.to_string(), val.to_string());
26052605
} else {
2606-
early_dcx.early_fatal(format!("`--env`: specify value for variable `{arg}`"));
2606+
early_dcx.early_fatal(format!("`--env-set`: specify value for variable `{arg}`"));
26072607
}
26082608
}
26092609

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `env`
1+
# `env-set`
22

33
The tracking issue for this feature is: [#118372](https://github.com/rust-lang/rust/issues/118372).
44

@@ -11,11 +11,11 @@ from the `proc_macro` crate.
1111
This information will be stored in the dep-info files. For more information about
1212
dep-info files, take a look [here](https://doc.rust-lang.org/cargo/guide/build-cache.html#dep-info-files).
1313

14-
When retrieving an environment variable value, the one specified by `--env` will take
14+
When retrieving an environment variable value, the one specified by `--env-set` will take
1515
precedence. For example, if you want have `PATH=a` in your environment and pass:
1616

1717
```bash
18-
rustc --env PATH=env
18+
rustc --env-set PATH=env
1919
```
2020

2121
Then you will have:
@@ -24,22 +24,22 @@ Then you will have:
2424
assert_eq!(env!("PATH"), "env");
2525
```
2626

27-
It will trigger a new compilation if any of the `--env` argument value is different.
27+
It will trigger a new compilation if any of the `--env-set` argument value is different.
2828
So if you first passed:
2929

3030
```bash
31-
--env A=B --env X=12
31+
--env-set A=B --env X=12
3232
```
3333

3434
and then on next compilation:
3535

3636
```bash
37-
--env A=B
37+
--env-set A=B
3838
```
3939

4040
`X` value is different (not set) so the code will be re-compiled.
4141

4242
Please note that on Windows, environment variables are case insensitive but case
4343
preserving whereas `rustc`'s environment variables are case sensitive. For example,
4444
having `Path` in your environment (case insensitive) is different than using
45-
`rustc --env Path=...` (case sensitive).
45+
`rustc --env-set Path=...` (case sensitive).

tests/ui/extenv/extenv-env-overload.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-pass
22
// rustc-env:MY_VAR=tadam
3-
// compile-flags: --env MY_VAR=123abc -Zunstable-options
3+
// compile-flags: --env-set MY_VAR=123abc -Zunstable-options
44

55
// This test ensures that variables provided with `--env` take precedence over
66
// variables from environment.

tests/ui/extenv/extenv-env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: --env FOO=123abc -Zunstable-options
1+
// compile-flags: --env-set FOO=123abc -Zunstable-options
22
// run-pass
33
fn main() {
44
assert_eq!(env!("FOO"), "123abc");

tests/ui/extenv/extenv-not-env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-pass
22
// rustc-env:MY_ENV=/
3-
// Ensures that variables not defined through `--env` are still available.
3+
// Ensures that variables not defined through `--env-set` are still available.
44

55
fn main() {
66
assert!(!env!("MY_ENV").is_empty());

tests/ui/feature-gates/env-flag.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
// compile-flags: --env A=B
1+
// compile-flags: --env-set A=B
22

33
fn main() {}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: the `-Z unstable-options` flag must also be passed to enable the flag `env`
1+
error: the `-Z unstable-options` flag must also be passed to enable the flag `env-set`
22

tests/ui/proc-macro/env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// aux-build:env.rs
22
// run-pass
33
// rustc-env: THE_CONST=1
4-
// compile-flags: -Zunstable-options --env THE_CONST=12 --env ANOTHER=4
4+
// compile-flags: -Zunstable-options --env-set THE_CONST=12 --env-set ANOTHER=4
55

66
#![crate_name = "foo"]
77

0 commit comments

Comments
 (0)