Skip to content

Commit 147bfa7

Browse files
committed
revert rust-lang#11080 and assert precondition for --directory flag
1 parent 5f445ce commit 147bfa7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/bin/cargo/cli.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ pub fn main(config: &mut LazyConfig) -> CliResult {
2828
let args = cli().try_get_matches()?;
2929

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

515+
/// Check whether the config is loaded
516+
///
517+
/// This is useful for asserts in case the environment needs to be setup before loading
518+
pub fn is_init(&self) -> bool {
519+
self.config.is_some()
520+
}
521+
513522
/// Get the config, loading it if needed
514523
///
515524
/// On error, the process is terminated

0 commit comments

Comments
 (0)