Skip to content

Commit e4135d4

Browse files
committed
Support x suggest with build-metrics
1 parent 79c6700 commit e4135d4

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/bootstrap/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ pub enum GitRepo {
191191
/// although most functions are implemented as free functions rather than
192192
/// methods specifically on this structure itself (to make it easier to
193193
/// organize).
194-
#[cfg_attr(not(feature = "build-metrics"), derive(Clone))]
194+
#[derive(Clone)]
195195
pub struct Build {
196196
/// User-specified configuration from `config.toml`.
197197
config: Config,

src/bootstrap/metrics.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ pub(crate) struct BuildMetrics {
4040
state: RefCell<MetricsState>,
4141
}
4242

43+
/// NOTE: this isn't really cloning anything, but `x suggest` doesn't need metrics so this is probably ok.
44+
impl Clone for BuildMetrics {
45+
fn clone(&self) -> Self {
46+
Self::init()
47+
}
48+
}
49+
4350
impl BuildMetrics {
4451
pub(crate) fn init() -> Self {
4552
let state = RefCell::new(MetricsState {

src/bootstrap/suggest.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@ use clap::Parser;
88

99
use crate::{builder::Builder, tool::Tool};
1010

11-
#[cfg(feature = "build-metrics")]
12-
pub fn suggest(builder: &Builder<'_>, run: bool) {
13-
panic!("`x suggest` is not supported with `build-metrics`")
14-
}
15-
1611
/// Suggests a list of possible `x.py` commands to run based on modified files in branch.
17-
#[cfg(not(feature = "build-metrics"))]
1812
pub fn suggest(builder: &Builder<'_>, run: bool) {
1913
let suggestions =
2014
builder.tool_cmd(Tool::SuggestTests).output().expect("failed to run `suggest-tests` tool");
@@ -66,7 +60,7 @@ pub fn suggest(builder: &Builder<'_>, run: bool) {
6660

6761
if run {
6862
for sug in suggestions {
69-
let mut build = builder.build.clone();
63+
let mut build: crate::Build = builder.build.clone();
7064
build.config.paths = sug.2;
7165
build.config.cmd = crate::flags::Flags::parse_from([sug.0]).cmd;
7266
if let Some(stage) = sug.1 {

0 commit comments

Comments
 (0)