mirror of
https://github.com/rust-lang/cargo
synced 2024-10-13 11:12:25 +00:00
revert #11080 and assert precondition for -C flag
This commit is contained in:
parent
4de2c96021
commit
6dacf8ba17
|
@ -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")?;
|
||||
}
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue