From 4ce2b61f2a08c45eae91641eb66a6698ea462ed0 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 31 May 2024 14:45:43 -0500 Subject: [PATCH] Revert "fix(context): Configure Shell before emitting messages" This reverts commit f525e1f383fc0d0a7adbdfb1bac6d6228ae79b33. This removes color control from warnings for unstable features. For some reason this removed color support from `cargo -Zhelp` in the tests but I can't reproduce it locally. The most important thing was getting the config fix in. There are two follow ups - Can we have the config working *and* color? - Why did this fail for this field and not the others we already had tests for? I ran out my immediate time box for looking into these. Fixes #13991 --- src/cargo/util/context/mod.rs | 50 +++++++------- tests/testsuite/cargo/z_help/stdout.term.svg | 69 ++++++++++---------- tests/testsuite/config_cli.rs | 4 +- 3 files changed, 60 insertions(+), 63 deletions(-) diff --git a/src/cargo/util/context/mod.rs b/src/cargo/util/context/mod.rs index 2ce4f2ace..85eeccab6 100644 --- a/src/cargo/util/context/mod.rs +++ b/src/cargo/util/context/mod.rs @@ -1020,6 +1020,31 @@ impl GlobalContext { unstable_flags: &[String], cli_config: &[String], ) -> CargoResult<()> { + for warning in self + .unstable_flags + .parse(unstable_flags, self.nightly_features_allowed)? + { + self.shell().warn(warning)?; + } + if !unstable_flags.is_empty() { + // store a copy of the cli flags separately for `load_unstable_flags_from_config` + // (we might also need it again for `reload_rooted_at`) + self.unstable_flags_cli = Some(unstable_flags.to_vec()); + } + if !cli_config.is_empty() { + self.cli_config = Some(cli_config.iter().map(|s| s.to_string()).collect()); + self.merge_cli_args()?; + } + if self.unstable_flags.config_include { + // If the config was already loaded (like when fetching the + // `[alias]` table), it was loaded with includes disabled because + // the `unstable_flags` hadn't been set up, yet. Any values + // fetched before this step will not process includes, but that + // should be fine (`[alias]` is one of the only things loaded + // before configure). This can be removed when stabilized. + self.reload_rooted_at(self.cwd.clone())?; + } + // Ignore errors in the configuration files. We don't want basic // commands like `cargo version` to error out due to config file // problems. @@ -1066,31 +1091,6 @@ impl GlobalContext { let cli_target_dir = target_dir.as_ref().map(|dir| Filesystem::new(dir.clone())); self.target_dir = cli_target_dir; - for warning in self - .unstable_flags - .parse(unstable_flags, self.nightly_features_allowed)? - { - self.shell().warn(warning)?; - } - if !unstable_flags.is_empty() { - // store a copy of the cli flags separately for `load_unstable_flags_from_config` - // (we might also need it again for `reload_rooted_at`) - self.unstable_flags_cli = Some(unstable_flags.to_vec()); - } - if !cli_config.is_empty() { - self.cli_config = Some(cli_config.iter().map(|s| s.to_string()).collect()); - self.merge_cli_args()?; - } - if self.unstable_flags.config_include { - // If the config was already loaded (like when fetching the - // `[alias]` table), it was loaded with includes disabled because - // the `unstable_flags` hadn't been set up, yet. Any values - // fetched before this step will not process includes, but that - // should be fine (`[alias]` is one of the only things loaded - // before configure). This can be removed when stabilized. - self.reload_rooted_at(self.cwd.clone())?; - } - self.load_unstable_flags_from_config()?; Ok(()) diff --git a/tests/testsuite/cargo/z_help/stdout.term.svg b/tests/testsuite/cargo/z_help/stdout.term.svg index c453ebc0b..a4c8e579b 100644 --- a/tests/testsuite/cargo/z_help/stdout.term.svg +++ b/tests/testsuite/cargo/z_help/stdout.term.svg @@ -2,13 +2,10 @@