Skip to content

Commit 1071cce

Browse files
committed
refactor(fix): Clarify env variable names are internal
1 parent 5ccca80 commit 1071cce

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/cargo/ops/fix.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
//! Cargo begins a normal `cargo check` operation with itself set as a proxy
1818
//! for rustc by setting `primary_unit_rustc` in the build config. When
1919
//! cargo launches rustc to check a crate, it is actually launching itself.
20-
//! The `FIX_ENV` environment variable is set so that cargo knows it is in
20+
//! The `FIX_ENV_INTERNAL` environment variable is set so that cargo knows it is in
2121
//! fix-proxy-mode.
2222
//!
23-
//! Each proxied cargo-as-rustc detects it is in fix-proxy-mode (via `FIX_ENV`
23+
//! Each proxied cargo-as-rustc detects it is in fix-proxy-mode (via `FIX_ENV_INTERNAL`
2424
//! environment variable in `main`) and does the following:
2525
//!
2626
//! - Acquire a lock from the `LockServer` from the master cargo process.
@@ -67,16 +67,16 @@ use crate::{drop_eprint, drop_eprintln};
6767
/// Indicates Cargo is in fix-proxy-mode if presents.
6868
/// The value of it is the socket address of the [`LockServer`] being used.
6969
/// See the [module-level documentation](mod@super::fix) for more.
70-
const FIX_ENV: &str = "__CARGO_FIX_PLZ";
70+
const FIX_ENV_INTERNAL: &str = "__CARGO_FIX_PLZ";
7171
/// **Internal only.**
7272
/// For passing [`FixOptions::broken_code`] through to cargo running in proxy mode.
73-
const BROKEN_CODE_ENV: &str = "__CARGO_FIX_BROKEN_CODE";
73+
const BROKEN_CODE_ENV_INTERNAL: &str = "__CARGO_FIX_BROKEN_CODE";
7474
/// **Internal only.**
7575
/// For passing [`FixOptions::edition`] through to cargo running in proxy mode.
76-
const EDITION_ENV: &str = "__CARGO_FIX_EDITION";
76+
const EDITION_ENV_INTERNAL: &str = "__CARGO_FIX_EDITION";
7777
/// **Internal only.**
7878
/// For passing [`FixOptions::idioms`] through to cargo running in proxy mode.
79-
const IDIOMS_ENV: &str = "__CARGO_FIX_IDIOMS";
79+
const IDIOMS_ENV_INTERNAL: &str = "__CARGO_FIX_IDIOMS";
8080

8181
pub struct FixOptions {
8282
pub edition: bool,
@@ -97,20 +97,20 @@ pub fn fix(ws: &Workspace<'_>, opts: &mut FixOptions) -> CargoResult<()> {
9797
// Spin up our lock server, which our subprocesses will use to synchronize fixes.
9898
let lock_server = LockServer::new()?;
9999
let mut wrapper = ProcessBuilder::new(env::current_exe()?);
100-
wrapper.env(FIX_ENV, lock_server.addr().to_string());
100+
wrapper.env(FIX_ENV_INTERNAL, lock_server.addr().to_string());
101101
let _started = lock_server.start()?;
102102

103103
opts.compile_opts.build_config.force_rebuild = true;
104104

105105
if opts.broken_code {
106-
wrapper.env(BROKEN_CODE_ENV, "1");
106+
wrapper.env(BROKEN_CODE_ENV_INTERNAL, "1");
107107
}
108108

109109
if opts.edition {
110-
wrapper.env(EDITION_ENV, "1");
110+
wrapper.env(EDITION_ENV_INTERNAL, "1");
111111
}
112112
if opts.idioms {
113-
wrapper.env(IDIOMS_ENV, "1");
113+
wrapper.env(IDIOMS_ENV_INTERNAL, "1");
114114
}
115115

116116
*opts
@@ -352,7 +352,7 @@ pub fn fix_get_proxy_lock_addr() -> Option<String> {
352352
// ALLOWED: For the internal mechanism of `cargo fix` only.
353353
// Shouldn't be set directly by anyone.
354354
#[allow(clippy::disallowed_methods)]
355-
env::var(FIX_ENV).ok()
355+
env::var(FIX_ENV_INTERNAL).ok()
356356
}
357357

358358
/// Entry point for `cargo` running as a proxy for `rustc`.
@@ -373,7 +373,7 @@ pub fn fix_exec_rustc(config: &Config, lock_addr: &str) -> CargoResult<()> {
373373
.ok();
374374
let mut rustc = ProcessBuilder::new(&args.rustc).wrapped(workspace_rustc.as_ref());
375375
rustc.retry_with_argfile(true);
376-
rustc.env_remove(FIX_ENV);
376+
rustc.env_remove(FIX_ENV_INTERNAL);
377377
args.apply(&mut rustc);
378378

379379
trace!("start rustfixing {:?}", args.file);
@@ -417,7 +417,7 @@ pub fn fix_exec_rustc(config: &Config, lock_addr: &str) -> CargoResult<()> {
417417
// user's code with our changes. Back out everything and fall through
418418
// below to recompile again.
419419
if !output.status.success() {
420-
if config.get_env_os(BROKEN_CODE_ENV).is_none() {
420+
if config.get_env_os(BROKEN_CODE_ENV_INTERNAL).is_none() {
421421
for (path, file) in fixes.files.iter() {
422422
debug!("reverting {:?} due to errors", path);
423423
paths::write(path, &file.original_code)?;
@@ -591,7 +591,7 @@ fn rustfix_and_fix(
591591
// worse by applying fixes where a bug could cause *more* broken code.
592592
// Instead, punt upwards which will reexec rustc over the original code,
593593
// displaying pretty versions of the diagnostics we just read out.
594-
if !output.status.success() && config.get_env_os(BROKEN_CODE_ENV).is_none() {
594+
if !output.status.success() && config.get_env_os(BROKEN_CODE_ENV_INTERNAL).is_none() {
595595
debug!(
596596
"rustfixing `{:?}` failed, rustc exited with {:?}",
597597
filename,
@@ -863,12 +863,12 @@ impl FixArgs {
863863
// ALLOWED: For the internal mechanism of `cargo fix` only.
864864
// Shouldn't be set directly by anyone.
865865
#[allow(clippy::disallowed_methods)]
866-
let idioms = env::var(IDIOMS_ENV).is_ok();
866+
let idioms = env::var(IDIOMS_ENV_INTERNAL).is_ok();
867867

868868
// ALLOWED: For the internal mechanism of `cargo fix` only.
869869
// Shouldn't be set directly by anyone.
870870
#[allow(clippy::disallowed_methods)]
871-
let prepare_for_edition = env::var(EDITION_ENV).ok().map(|_| {
871+
let prepare_for_edition = env::var(EDITION_ENV_INTERNAL).ok().map(|_| {
872872
enabled_edition
873873
.unwrap_or(Edition::Edition2015)
874874
.saturating_next()

0 commit comments

Comments
 (0)