Skip to content

Commit e76ae3e

Browse files
authored
Rollup merge of #113644 - jyn514:bootstrap-cleanups, r=albertlarsan68
misc bootstrap cleanups - rename `detail_exit_macro` to `exit` - remove unnecessary `Builder::new_standalone` function - support `x suggest` with build-metrics
2 parents da18cf8 + dc48a8b commit e76ae3e

File tree

17 files changed

+56
-68
lines changed

17 files changed

+56
-68
lines changed

src/bootstrap/builder.rs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ impl StepDescription {
395395
eprintln!(
396396
"note: if you are adding a new Step to bootstrap itself, make sure you register it with `describe!`"
397397
);
398-
crate::detail_exit_macro!(1);
398+
crate::exit!(1);
399399
}
400400
}
401401
}
@@ -939,21 +939,6 @@ impl<'a> Builder<'a> {
939939
Self::new_internal(build, kind, paths.to_owned())
940940
}
941941

942-
/// Creates a new standalone builder for use outside of the normal process
943-
pub fn new_standalone(
944-
build: &mut Build,
945-
kind: Kind,
946-
paths: Vec<PathBuf>,
947-
stage: Option<u32>,
948-
) -> Builder<'_> {
949-
// FIXME: don't mutate `build`
950-
if let Some(stage) = stage {
951-
build.config.stage = stage;
952-
}
953-
954-
Self::new_internal(build, kind, paths.to_owned())
955-
}
956-
957942
pub fn execute_cli(&self) {
958943
self.run_step_descriptions(&Builder::get_step_descriptions(self.kind), &self.paths);
959944
}
@@ -1375,7 +1360,7 @@ impl<'a> Builder<'a> {
13751360
"error: `x.py clippy` requires a host `rustc` toolchain with the `clippy` component"
13761361
);
13771362
eprintln!("help: try `rustup component add clippy`");
1378-
crate::detail_exit_macro!(1);
1363+
crate::exit!(1);
13791364
});
13801365
if !t!(std::str::from_utf8(&output.stdout)).contains("nightly") {
13811366
rustflags.arg("--cfg=bootstrap");

src/bootstrap/compile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,7 @@ pub fn run_cargo(
18201820
});
18211821

18221822
if !ok {
1823-
crate::detail_exit_macro!(1);
1823+
crate::exit!(1);
18241824
}
18251825

18261826
// Ok now we need to actually find all the files listed in `toplevel`. We've

src/bootstrap/config.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::channel::{self, GitInfo};
2323
pub use crate::flags::Subcommand;
2424
use crate::flags::{Color, Flags, Warnings};
2525
use crate::util::{exe, output, t};
26-
use build_helper::detail_exit_macro;
26+
use build_helper::exit;
2727
use once_cell::sync::OnceCell;
2828
use semver::Version;
2929
use serde::{Deserialize, Deserializer};
@@ -646,7 +646,7 @@ macro_rules! define_config {
646646
panic!("overriding existing option")
647647
} else {
648648
eprintln!("overriding existing option: `{}`", stringify!($field));
649-
detail_exit_macro!(2);
649+
exit!(2);
650650
}
651651
} else {
652652
self.$field = other.$field;
@@ -745,7 +745,7 @@ impl<T> Merge for Option<T> {
745745
panic!("overriding existing option")
746746
} else {
747747
eprintln!("overriding existing option");
748-
detail_exit_macro!(2);
748+
exit!(2);
749749
}
750750
} else {
751751
*self = other;
@@ -1101,7 +1101,7 @@ impl Config {
11011101
.and_then(|table: toml::Value| TomlConfig::deserialize(table))
11021102
.unwrap_or_else(|err| {
11031103
eprintln!("failed to parse TOML configuration '{}': {err}", file.display());
1104-
detail_exit_macro!(2);
1104+
exit!(2);
11051105
})
11061106
}
11071107
Self::parse_inner(args, get_toml)
@@ -1135,7 +1135,7 @@ impl Config {
11351135
eprintln!(
11361136
"Cannot use both `llvm_bolt_profile_generate` and `llvm_bolt_profile_use` at the same time"
11371137
);
1138-
detail_exit_macro!(1);
1138+
exit!(1);
11391139
}
11401140

11411141
// Infer the rest of the configuration.
@@ -1259,7 +1259,7 @@ impl Config {
12591259
}
12601260
}
12611261
eprintln!("failed to parse override `{option}`: `{err}");
1262-
detail_exit_macro!(2)
1262+
exit!(2)
12631263
}
12641264
toml.merge(override_toml, ReplaceOpt::Override);
12651265

@@ -2007,7 +2007,7 @@ impl Config {
20072007
"Unexpected rustc version: {}, we should use {}/{} to build source with {}",
20082008
rustc_version, prev_version, source_version, source_version
20092009
);
2010-
detail_exit_macro!(1);
2010+
exit!(1);
20112011
}
20122012
}
20132013

@@ -2043,7 +2043,7 @@ impl Config {
20432043
println!("help: maybe your repository history is too shallow?");
20442044
println!("help: consider disabling `download-rustc`");
20452045
println!("help: or fetch enough history to include one upstream commit");
2046-
crate::detail_exit_macro!(1);
2046+
crate::exit!(1);
20472047
}
20482048

20492049
// Warn if there were changes to the compiler or standard library since the ancestor commit.

src/bootstrap/download.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ impl Config {
253253
if !help_on_error.is_empty() {
254254
eprintln!("{}", help_on_error);
255255
}
256-
crate::detail_exit_macro!(1);
256+
crate::exit!(1);
257257
}
258258
}
259259

src/bootstrap/flags.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl Flags {
193193
} else {
194194
panic!("No paths available for subcommand `{}`", subcommand.as_str());
195195
}
196-
crate::detail_exit_macro!(0);
196+
crate::exit!(0);
197197
}
198198

199199
Flags::parse_from(it)
@@ -538,7 +538,7 @@ pub fn get_completion<G: clap_complete::Generator>(shell: G, path: &Path) -> Opt
538538
} else {
539539
std::fs::read_to_string(path).unwrap_or_else(|_| {
540540
eprintln!("couldn't read {}", path.display());
541-
crate::detail_exit_macro!(1)
541+
crate::exit!(1)
542542
})
543543
};
544544
let mut buf = Vec::new();

src/bootstrap/format.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn rustfmt(src: &Path, rustfmt: &Path, paths: &[PathBuf], check: bool) -> impl F
4040
code, run `./x.py fmt` instead.",
4141
cmd_debug,
4242
);
43-
crate::detail_exit_macro!(1);
43+
crate::exit!(1);
4444
}
4545
true
4646
}
@@ -200,7 +200,7 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
200200

201201
let rustfmt_path = build.initial_rustfmt().unwrap_or_else(|| {
202202
eprintln!("./x.py fmt is not supported on this channel");
203-
crate::detail_exit_macro!(1);
203+
crate::exit!(1);
204204
});
205205
assert!(rustfmt_path.exists(), "{}", rustfmt_path.display());
206206
let src = build.src.clone();

src/bootstrap/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use std::process::{Command, Stdio};
2727
use std::str;
2828

2929
use build_helper::ci::{gha, CiEnv};
30-
use build_helper::detail_exit_macro;
30+
use build_helper::exit;
3131
use channel::GitInfo;
3232
use config::{DryRun, Target};
3333
use filetime::FileTime;
@@ -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,
@@ -711,7 +711,7 @@ impl Build {
711711
for failure in failures.iter() {
712712
eprintln!(" - {}\n", failure);
713713
}
714-
detail_exit_macro!(1);
714+
exit!(1);
715715
}
716716

717717
#[cfg(feature = "build-metrics")]
@@ -1529,7 +1529,7 @@ impl Build {
15291529
"Error: Unable to find the stamp file {}, did you try to keep a nonexistent build stage?",
15301530
stamp.display()
15311531
);
1532-
crate::detail_exit_macro!(1);
1532+
crate::exit!(1);
15331533
}
15341534

15351535
let mut paths = Vec::new();
@@ -1721,7 +1721,7 @@ Alternatively, set `download-ci-llvm = true` in that `[llvm]` section
17211721
to download LLVM rather than building it.
17221722
"
17231723
);
1724-
detail_exit_macro!(1);
1724+
exit!(1);
17251725
}
17261726
}
17271727

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/render_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub(crate) fn try_run_tests(builder: &Builder<'_>, cmd: &mut Command, stream: bo
3030

3131
if !run_tests(builder, cmd, stream) {
3232
if builder.fail_fast {
33-
crate::detail_exit_macro!(1);
33+
crate::exit!(1);
3434
} else {
3535
let mut failures = builder.delayed_failures.borrow_mut();
3636
failures.push(format!("{cmd:?}"));

src/bootstrap/sanity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ You should install cmake, or set `download-ci-llvm = true` in the
104104
than building it.
105105
"
106106
);
107-
crate::detail_exit_macro!(1);
107+
crate::exit!(1);
108108
}
109109
}
110110

0 commit comments

Comments
 (0)