Skip to content

Commit 9f232e5

Browse files
committed
tweak: do not avoid tracking env vars repeatedly
1 parent 6de77e9 commit 9f232e5

File tree

1 file changed

+1
-22
lines changed
  • sqlx-macros-core/src/query

1 file changed

+1
-22
lines changed

sqlx-macros-core/src/query/mod.rs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -418,23 +418,13 @@ where
418418
Ok(ret_tokens)
419419
}
420420

421-
#[cfg(procmacro2_semver_exempt)]
422-
static TRACKED_ENV_VARS: Mutex<HashSet<String, BuildHasherDefault<DefaultHasher>>> =
423-
Mutex::new(HashSet::with_hasher(BuildHasherDefault::new()));
424-
425421
static LOADED_ENV_VARS: Mutex<HashMap<String, String, BuildHasherDefault<DefaultHasher>>> =
426422
Mutex::new(HashMap::with_hasher(BuildHasherDefault::new()));
427423

428424
/// Get the value of an environment variable, telling the compiler about it if applicable.
429425
fn env(name: &str) -> Result<String, std::env::VarError> {
430426
#[cfg(procmacro2_semver_exempt)]
431-
let tracked_value = if TRACKED_ENV_VARS.lock().unwrap().insert(name.to_string()) {
432-
// Avoid tracking the same env var multiple times, which would undesirably modify
433-
// build system state and thus behavior in case we change var values.
434-
Some(proc_macro::tracked_env::var(name))
435-
} else {
436-
None
437-
};
427+
let tracked_value = Some(proc_macro::tracked_env::var(name));
438428
#[cfg(not(procmacro2_semver_exempt))]
439429
let tracked_value = None;
440430

@@ -473,17 +463,6 @@ fn load_env(manifest_dir: &Path, config: &Config) {
473463
}
474464
}
475465

476-
// Tell the compiler about the environment variables we care about before we load them
477-
// from any `.env`, so the build system can react to changes in their original values,
478-
// not the values we load from a potential `.env` file tracked above, which should not
479-
// take precedence.
480-
#[cfg(procmacro2_semver_exempt)]
481-
for name in &loadable_vars {
482-
if TRACKED_ENV_VARS.lock().unwrap().insert(name.to_string()) {
483-
proc_macro::tracked_env::var(name);
484-
}
485-
}
486-
487466
if let Some(dotenv_path) = found_dotenv
488467
.then_some(candidate_dotenv_paths)
489468
.iter()

0 commit comments

Comments
 (0)