From 441972d18b05f8bd1bb2f05c0aad4f242ebe77a5 Mon Sep 17 00:00:00 2001 From: jyn Date: Thu, 13 Jul 2023 02:28:07 -0500 Subject: Rename `detail_exit_macro` to `exit` `detail` and `macro` weren't adding any info. --- src/bootstrap/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/bootstrap/lib.rs') diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 0b509132043..da04386b30a 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -27,7 +27,7 @@ use std::process::{Command, Stdio}; use std::str; use build_helper::ci::{gha, CiEnv}; -use build_helper::detail_exit_macro; +use build_helper::exit; use channel::GitInfo; use config::{DryRun, Target}; use filetime::FileTime; @@ -711,7 +711,7 @@ impl Build { for failure in failures.iter() { eprintln!(" - {}\n", failure); } - detail_exit_macro!(1); + exit!(1); } #[cfg(feature = "build-metrics")] @@ -1515,7 +1515,7 @@ impl Build { "Error: Unable to find the stamp file {}, did you try to keep a nonexistent build stage?", stamp.display() ); - crate::detail_exit_macro!(1); + crate::exit!(1); } let mut paths = Vec::new(); @@ -1707,7 +1707,7 @@ Alternatively, set `download-ci-llvm = true` in that `[llvm]` section to download LLVM rather than building it. " ); - detail_exit_macro!(1); + exit!(1); } } -- cgit 1.4.1-3-g733a5 From e4135d4cd41a52000b31698615084f74faccaa1f Mon Sep 17 00:00:00 2001 From: jyn Date: Thu, 13 Jul 2023 03:19:42 -0500 Subject: Support `x suggest` with build-metrics --- src/bootstrap/lib.rs | 2 +- src/bootstrap/metrics.rs | 7 +++++++ src/bootstrap/suggest.rs | 8 +------- 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src/bootstrap/lib.rs') diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index da04386b30a..9242386d187 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -191,7 +191,7 @@ pub enum GitRepo { /// although most functions are implemented as free functions rather than /// methods specifically on this structure itself (to make it easier to /// organize). -#[cfg_attr(not(feature = "build-metrics"), derive(Clone))] +#[derive(Clone)] pub struct Build { /// User-specified configuration from `config.toml`. config: Config, diff --git a/src/bootstrap/metrics.rs b/src/bootstrap/metrics.rs index b73df7fe822..cf8d33dfcb0 100644 --- a/src/bootstrap/metrics.rs +++ b/src/bootstrap/metrics.rs @@ -40,6 +40,13 @@ pub(crate) struct BuildMetrics { state: RefCell, } +/// NOTE: this isn't really cloning anything, but `x suggest` doesn't need metrics so this is probably ok. +impl Clone for BuildMetrics { + fn clone(&self) -> Self { + Self::init() + } +} + impl BuildMetrics { pub(crate) fn init() -> Self { let state = RefCell::new(MetricsState { diff --git a/src/bootstrap/suggest.rs b/src/bootstrap/suggest.rs index 85278c70c94..a8c95b11e38 100644 --- a/src/bootstrap/suggest.rs +++ b/src/bootstrap/suggest.rs @@ -8,13 +8,7 @@ use clap::Parser; use crate::{builder::Builder, tool::Tool}; -#[cfg(feature = "build-metrics")] -pub fn suggest(builder: &Builder<'_>, run: bool) { - panic!("`x suggest` is not supported with `build-metrics`") -} - /// Suggests a list of possible `x.py` commands to run based on modified files in branch. -#[cfg(not(feature = "build-metrics"))] pub fn suggest(builder: &Builder<'_>, run: bool) { let suggestions = builder.tool_cmd(Tool::SuggestTests).output().expect("failed to run `suggest-tests` tool"); @@ -66,7 +60,7 @@ pub fn suggest(builder: &Builder<'_>, run: bool) { if run { for sug in suggestions { - let mut build = builder.build.clone(); + let mut build: crate::Build = builder.build.clone(); build.config.paths = sug.2; build.config.cmd = crate::flags::Flags::parse_from([sug.0]).cmd; if let Some(stage) = sug.1 { -- cgit 1.4.1-3-g733a5