Skip to content

Commit

Permalink
revert rust-lang#11080 and assert precondition for -C flag
Browse files Browse the repository at this point in the history
  • Loading branch information
compenguy authored and Ethan-000 committed Feb 11, 2023
1 parent 2b8eda1 commit 03c6a1d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/bin/cargo/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub fn main(config: &mut LazyConfig) -> CliResult {
let args = cli().try_get_matches()?;

// Update the process-level notion of cwd
// This must be completed before config is initialized
assert_eq!(config.is_init(), false);
if let Some(new_cwd) = args.get_one::<std::path::PathBuf>("directory") {
std::env::set_current_dir(&new_cwd).context("could not change to requested directory")?;
}
Expand Down Expand Up @@ -510,6 +512,13 @@ impl LazyConfig {
Self { config: None }
}

/// Check whether the config is loaded
///
/// This is useful for asserts in case the environment needs to be setup before loading
pub fn is_init(&self) -> bool {
self.config.is_some()
}

/// Get the config, loading it if needed
///
/// On error, the process is terminated
Expand Down

0 comments on commit 03c6a1d

Please sign in to comment.