about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2024-01-12 11:02:57 +0100
committerGuillaume Gomez <guillaume.gomez@huawei.com>2024-01-12 11:02:57 +0100
commit462bcac629752d4f5d8bf87adcba9dab96044ed5 (patch)
tree4f89e8553f84f1fdbd0f988b6a9195fb40565d1e
parent2b1365b34f0d5ee43944c4266a625923a7b312dd (diff)
downloadrust-462bcac629752d4f5d8bf87adcba9dab96044ed5.tar.gz
rust-462bcac629752d4f5d8bf87adcba9dab96044ed5.zip
Rename `--env` option flag to `--env-set`
-rw-r--r--compiler/rustc_builtin_macros/src/env.rs2
-rw-r--r--compiler/rustc_session/src/config.rs6
-rw-r--r--src/doc/unstable-book/src/compiler-flags/env-set.md (renamed from src/doc/unstable-book/src/compiler-flags/env.md)14
-rw-r--r--tests/ui/extenv/extenv-env-overload.rs2
-rw-r--r--tests/ui/extenv/extenv-env.rs2
-rw-r--r--tests/ui/extenv/extenv-not-env.rs2
-rw-r--r--tests/ui/feature-gates/env-flag.rs2
-rw-r--r--tests/ui/feature-gates/env-flag.stderr2
-rw-r--r--tests/ui/proc-macro/env.rs2
9 files changed, 17 insertions, 17 deletions
diff --git a/compiler/rustc_builtin_macros/src/env.rs b/compiler/rustc_builtin_macros/src/env.rs
index 4b3eaf78557..a0fd0e3f9be 100644
--- a/compiler/rustc_builtin_macros/src/env.rs
+++ b/compiler/rustc_builtin_macros/src/env.rs
@@ -18,7 +18,7 @@ fn lookup_env<'cx>(cx: &'cx ExtCtxt<'_>, var: Symbol) -> Option<Symbol> {
     if let Some(value) = cx.sess.opts.logical_env.get(var) {
         return Some(Symbol::intern(value));
     }
-    // If the environment variable was not defined with the `--env` option, we try to retrieve it
+    // If the environment variable was not defined with the `--env-set` option, we try to retrieve it
     // from rustc's environment.
     env::var(var).ok().as_deref().map(Symbol::intern)
 }
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs
index 61796d7a6ca..ba04a3222ba 100644
--- a/compiler/rustc_session/src/config.rs
+++ b/compiler/rustc_session/src/config.rs
@@ -1823,7 +1823,7 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
             "Remap source names in all output (compiler messages and output files)",
             "FROM=TO",
         ),
-        opt::multi("", "env", "Inject an environment variable", "VAR=VALUE"),
+        opt::multi("", "env-set", "Inject an environment variable", "VAR=VALUE"),
     ]);
     opts
 }
@@ -2599,11 +2599,11 @@ fn parse_logical_env(
 ) -> FxIndexMap<String, String> {
     let mut vars = FxIndexMap::default();
 
-    for arg in matches.opt_strs("env") {
+    for arg in matches.opt_strs("env-set") {
         if let Some((name, val)) = arg.split_once('=') {
             vars.insert(name.to_string(), val.to_string());
         } else {
-            early_dcx.early_fatal(format!("`--env`: specify value for variable `{arg}`"));
+            early_dcx.early_fatal(format!("`--env-set`: specify value for variable `{arg}`"));
         }
     }
 
diff --git a/src/doc/unstable-book/src/compiler-flags/env.md b/src/doc/unstable-book/src/compiler-flags/env-set.md
index ac6d7474a9b..e5d7206c3a3 100644
--- a/src/doc/unstable-book/src/compiler-flags/env.md
+++ b/src/doc/unstable-book/src/compiler-flags/env-set.md
@@ -1,4 +1,4 @@
-# `env`
+# `env-set`
 
 The tracking issue for this feature is: [#118372](https://github.com/rust-lang/rust/issues/118372).
 
@@ -11,11 +11,11 @@ from the `proc_macro` crate.
 This information will be stored in the dep-info files. For more information about
 dep-info files, take a look [here](https://doc.rust-lang.org/cargo/guide/build-cache.html#dep-info-files).
 
-When retrieving an environment variable value, the one specified by `--env` will take
+When retrieving an 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:
 
 ```bash
-rustc --env PATH=env
+rustc --env-set PATH=env
 ```
 
 Then you will have:
@@ -24,17 +24,17 @@ Then you will have:
 assert_eq!(env!("PATH"), "env");
 ```
 
-It will trigger a new compilation if any of the `--env` argument value is different.
+It will trigger a new compilation if any of the `--env-set` argument value is different.
 So if you first passed:
 
 ```bash
---env A=B --env X=12
+--env-set A=B --env X=12
 ```
 
 and then on next compilation:
 
 ```bash
---env A=B
+--env-set A=B
 ```
 
 `X` value is different (not set) so the code will be re-compiled.
@@ -42,4 +42,4 @@ and then on next compilation:
 Please note that on Windows, environment variables are case insensitive but case
 preserving whereas `rustc`'s environment variables are case sensitive. For example,
 having `Path` in your environment (case insensitive) is different than using
-`rustc --env Path=...` (case sensitive).
+`rustc --env-set Path=...` (case sensitive).
diff --git a/tests/ui/extenv/extenv-env-overload.rs b/tests/ui/extenv/extenv-env-overload.rs
index b82bb2fe966..8b3b565fe83 100644
--- a/tests/ui/extenv/extenv-env-overload.rs
+++ b/tests/ui/extenv/extenv-env-overload.rs
@@ -1,6 +1,6 @@
 // run-pass
 // rustc-env:MY_VAR=tadam
-// compile-flags: --env MY_VAR=123abc -Zunstable-options
+// compile-flags: --env-set MY_VAR=123abc -Zunstable-options
 
 // This test ensures that variables provided with `--env` take precedence over
 // variables from environment.
diff --git a/tests/ui/extenv/extenv-env.rs b/tests/ui/extenv/extenv-env.rs
index 9fda52b8941..051ea214c1b 100644
--- a/tests/ui/extenv/extenv-env.rs
+++ b/tests/ui/extenv/extenv-env.rs
@@ -1,4 +1,4 @@
-// compile-flags: --env FOO=123abc -Zunstable-options
+// compile-flags: --env-set FOO=123abc -Zunstable-options
 // run-pass
 fn main() {
     assert_eq!(env!("FOO"), "123abc");
diff --git a/tests/ui/extenv/extenv-not-env.rs b/tests/ui/extenv/extenv-not-env.rs
index d6c4a43b003..b0355e073e4 100644
--- a/tests/ui/extenv/extenv-not-env.rs
+++ b/tests/ui/extenv/extenv-not-env.rs
@@ -1,6 +1,6 @@
 // run-pass
 // rustc-env:MY_ENV=/
-// Ensures that variables not defined through `--env` are still available.
+// Ensures that variables not defined through `--env-set` are still available.
 
 fn main() {
     assert!(!env!("MY_ENV").is_empty());
diff --git a/tests/ui/feature-gates/env-flag.rs b/tests/ui/feature-gates/env-flag.rs
index 9dfda2584fb..598773cf3e4 100644
--- a/tests/ui/feature-gates/env-flag.rs
+++ b/tests/ui/feature-gates/env-flag.rs
@@ -1,3 +1,3 @@
-// compile-flags: --env A=B
+// compile-flags: --env-set A=B
 
 fn main() {}
diff --git a/tests/ui/feature-gates/env-flag.stderr b/tests/ui/feature-gates/env-flag.stderr
index 5cb18cef9fb..a9fa1b65ea1 100644
--- a/tests/ui/feature-gates/env-flag.stderr
+++ b/tests/ui/feature-gates/env-flag.stderr
@@ -1,2 +1,2 @@
-error: the `-Z unstable-options` flag must also be passed to enable the flag `env`
+error: the `-Z unstable-options` flag must also be passed to enable the flag `env-set`
 
diff --git a/tests/ui/proc-macro/env.rs b/tests/ui/proc-macro/env.rs
index 1b1d1873eb3..c0edda4f7df 100644
--- a/tests/ui/proc-macro/env.rs
+++ b/tests/ui/proc-macro/env.rs
@@ -1,7 +1,7 @@
 // aux-build:env.rs
 // run-pass
 // rustc-env: THE_CONST=1
-// compile-flags: -Zunstable-options --env THE_CONST=12 --env ANOTHER=4
+// compile-flags: -Zunstable-options --env-set THE_CONST=12 --env-set ANOTHER=4
 
 #![crate_name = "foo"]