Skip to content

Commit 8ea9122

Browse files
committed
Rename verbose to do_if_verbose
1 parent 5a6e3cc commit 8ea9122

File tree

13 files changed

+40
-37
lines changed

13 files changed

+40
-37
lines changed

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,8 +1832,9 @@ impl Step for Sysroot {
18321832
let sysroot = sysroot_dir(compiler.stage);
18331833
trace!(stage = ?compiler.stage, ?sysroot);
18341834

1835-
builder
1836-
.verbose(|| println!("Removing sysroot {} to avoid caching bugs", sysroot.display()));
1835+
builder.do_if_verbose(|| {
1836+
println!("Removing sysroot {} to avoid caching bugs", sysroot.display())
1837+
});
18371838
let _ = fs::remove_dir_all(&sysroot);
18381839
t!(fs::create_dir_all(&sysroot));
18391840

@@ -2591,7 +2592,7 @@ pub fn stream_cargo(
25912592
cmd.arg(arg);
25922593
}
25932594

2594-
builder.verbose(|| println!("running: {cmd:?}"));
2595+
builder.do_if_verbose(|| println!("running: {cmd:?}"));
25952596

25962597
let streaming_command = cmd.stream_capture_stdout(&builder.config.exec_ctx);
25972598

src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2304,7 +2304,7 @@ fn maybe_install_llvm(
23042304
let mut cmd = command(host_llvm_config);
23052305
cmd.cached();
23062306
cmd.arg("--libfiles");
2307-
builder.verbose(|| println!("running {cmd:?}"));
2307+
builder.do_if_verbose(|| println!("running {cmd:?}"));
23082308
let files = cmd.run_capture_stdout(builder).stdout();
23092309
let build_llvm_out = &builder.llvm_out(builder.config.host_target);
23102310
let target_llvm_out = &builder.llvm_out(target);

src/bootstrap/src/core/build_steps/gcc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ fn try_download_gcc(builder: &Builder<'_>, target: TargetSelection) -> Option<Pa
128128
&builder.config,
129129
builder.config.rust_info.is_managed_git_subrepository(),
130130
);
131-
builder.verbose(|| {
131+
builder.do_if_verbose(|| {
132132
eprintln!("GCC freshness: {source:?}");
133133
});
134134
match source {

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,11 +582,11 @@ impl Miri {
582582
// We re-use the `cargo` from above.
583583
cargo.arg("--print-sysroot");
584584

585-
builder.verbose(|| println!("running: {cargo:?}"));
585+
builder.do_if_verbose(|| println!("running: {cargo:?}"));
586586
let stdout = cargo.run_capture_stdout(builder).stdout();
587587
// Output is "<sysroot>\n".
588588
let sysroot = stdout.trim_end();
589-
builder.verbose(|| println!("`cargo miri setup --print-sysroot` said: {sysroot:?}"));
589+
builder.do_if_verbose(|| println!("`cargo miri setup --print-sysroot` said: {sysroot:?}"));
590590
PathBuf::from(sysroot)
591591
}
592592
}
@@ -2675,7 +2675,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) ->
26752675
return true;
26762676
}
26772677

2678-
builder.verbose(|| println!("doc tests for: {}", markdown.display()));
2678+
builder.do_if_verbose(|| println!("doc tests for: {}", markdown.display()));
26792679
let mut cmd = builder.rustdoc_cmd(compiler);
26802680
builder.add_rust_test_threads(&mut cmd);
26812681
// allow for unstable options such as new editions

src/bootstrap/src/core/builder/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ impl StepDescription {
545545
if !builder.config.skip.is_empty()
546546
&& !matches!(builder.config.get_dry_run(), DryRun::SelfCheck)
547547
{
548-
builder.verbose(|| {
548+
builder.do_if_verbose(|| {
549549
println!(
550550
"{:?} not skipped for {:?} -- not in {:?}",
551551
pathset, self.name, builder.config.skip
@@ -947,7 +947,7 @@ impl Step for Libdir {
947947
// Sysroot`).
948948
if !builder.download_rustc() {
949949
let sysroot_target_libdir = sysroot.join(self.target).join("lib");
950-
builder.verbose(|| {
950+
builder.do_if_verbose(|| {
951951
eprintln!(
952952
"Removing sysroot {} to avoid caching bugs",
953953
sysroot_target_libdir.display()

src/bootstrap/src/core/config/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,8 +1571,8 @@ impl Config {
15711571
}
15721572

15731573
/// Runs a function if verbosity is greater than 0
1574-
pub fn verbose(&self, f: impl Fn()) {
1575-
self.exec_ctx.verbose(f);
1574+
pub fn do_if_verbose(&self, f: impl Fn()) {
1575+
self.exec_ctx.do_if_verbose(f);
15761576
}
15771577

15781578
pub fn any_sanitizers_to_build(&self) -> bool {
@@ -2061,7 +2061,7 @@ pub fn download_ci_rustc_commit<'a>(
20612061
// Look for a version to compare to based on the current commit.
20622062
// Only commits merged by bors will have CI artifacts.
20632063
let freshness = check_path_modifications_(dwn_ctx, RUSTC_IF_UNCHANGED_ALLOWED_PATHS);
2064-
dwn_ctx.exec_ctx.verbose(|| {
2064+
dwn_ctx.exec_ctx.do_if_verbose(|| {
20652065
eprintln!("rustc freshness: {freshness:?}");
20662066
});
20672067
match freshness {

src/bootstrap/src/core/download.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ enum DownloadSource {
106106
/// Functions that are only ever called once, but named for clarity and to avoid thousand-line functions.
107107
impl Config {
108108
pub(crate) fn download_clippy(&self) -> PathBuf {
109-
self.verbose(|| println!("downloading stage0 clippy artifacts"));
109+
self.do_if_verbose(|| println!("downloading stage0 clippy artifacts"));
110110

111111
let date = &self.stage0_metadata.compiler.date;
112112
let version = &self.stage0_metadata.compiler.version;
@@ -151,7 +151,9 @@ impl Config {
151151
}
152152

153153
pub(crate) fn download_ci_rustc(&self, commit: &str) {
154-
self.verbose(|| println!("using downloaded stage2 artifacts from CI (commit {commit})"));
154+
self.do_if_verbose(|| {
155+
println!("using downloaded stage2 artifacts from CI (commit {commit})")
156+
});
155157

156158
let version = self.artifact_version_part(commit);
157159
// download-rustc doesn't need its own cargo, it can just use beta's. But it does need the
@@ -258,7 +260,7 @@ impl Config {
258260
let llvm_root = self.ci_llvm_root();
259261
let llvm_freshness =
260262
detect_llvm_freshness(self, self.rust_info.is_managed_git_subrepository());
261-
self.verbose(|| {
263+
self.do_if_verbose(|| {
262264
eprintln!("LLVM freshness: {llvm_freshness:?}");
263265
});
264266
let llvm_sha = match llvm_freshness {
@@ -557,7 +559,7 @@ pub(crate) fn download_beta_toolchain<'a>(dwn_ctx: impl AsRef<DownloadContext<'a
557559
#[cfg(not(test))]
558560
pub(crate) fn download_beta_toolchain<'a>(dwn_ctx: impl AsRef<DownloadContext<'a>>, out: &Path) {
559561
let dwn_ctx = dwn_ctx.as_ref();
560-
dwn_ctx.exec_ctx.verbose(|| {
562+
dwn_ctx.exec_ctx.do_if_verbose(|| {
561563
println!("downloading stage0 beta artifacts");
562564
});
563565

@@ -812,7 +814,7 @@ fn download_component<'a>(
812814
unpack(dwn_ctx.exec_ctx, &tarball, &bin_root, prefix);
813815
return;
814816
} else {
815-
dwn_ctx.exec_ctx.verbose(|| {
817+
dwn_ctx.exec_ctx.do_if_verbose(|| {
816818
println!(
817819
"ignoring cached file {} due to failed verification",
818820
tarball.display()
@@ -853,7 +855,7 @@ download-rustc = false
853855
pub(crate) fn verify(exec_ctx: &ExecutionContext, path: &Path, expected: &str) -> bool {
854856
use sha2::Digest;
855857

856-
exec_ctx.verbose(|| {
858+
exec_ctx.do_if_verbose(|| {
857859
println!("verifying {}", path.display());
858860
});
859861

@@ -934,7 +936,7 @@ fn unpack(exec_ctx: &ExecutionContext, tarball: &Path, dst: &Path, pattern: &str
934936
short_path = short_path.strip_prefix(pattern).unwrap_or(short_path);
935937
let dst_path = dst.join(short_path);
936938

937-
exec_ctx.verbose(|| {
939+
exec_ctx.do_if_verbose(|| {
938940
println!("extracting {} to {}", original_path.display(), dst.display());
939941
});
940942

@@ -965,7 +967,7 @@ fn download_file<'a>(
965967
) {
966968
let dwn_ctx = dwn_ctx.as_ref();
967969

968-
dwn_ctx.exec_ctx.verbose(|| {
970+
dwn_ctx.exec_ctx.do_if_verbose(|| {
969971
println!("download {url}");
970972
});
971973
// Use a temporary file in case we crash while downloading, to avoid a corrupt download in cache/.

src/bootstrap/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ macro_rules! forward {
415415
}
416416

417417
forward! {
418-
verbose(f: impl Fn()),
418+
do_if_verbose(f: impl Fn()),
419419
is_verbose() -> bool,
420420
create(path: &Path, s: &str),
421421
remove(f: &Path),
@@ -601,19 +601,19 @@ impl Build {
601601
.unwrap()
602602
.trim();
603603
if local_release.split('.').take(2).eq(version.split('.').take(2)) {
604-
build.verbose(|| println!("auto-detected local-rebuild {local_release}"));
604+
build.do_if_verbose(|| println!("auto-detected local-rebuild {local_release}"));
605605
build.local_rebuild = true;
606606
}
607607

608-
build.verbose(|| println!("finding compilers"));
608+
build.do_if_verbose(|| println!("finding compilers"));
609609
utils::cc_detect::fill_compilers(&mut build);
610610
// When running `setup`, the profile is about to change, so any requirements we have now may
611611
// be different on the next invocation. Don't check for them until the next time x.py is
612612
// run. This is ok because `setup` never runs any build commands, so it won't fail if commands are missing.
613613
//
614614
// Similarly, for `setup` we don't actually need submodules or cargo metadata.
615615
if !matches!(build.config.cmd, Subcommand::Setup { .. }) {
616-
build.verbose(|| println!("running sanity check"));
616+
build.do_if_verbose(|| println!("running sanity check"));
617617
crate::core::sanity::check(&mut build);
618618

619619
// Make sure we update these before gathering metadata so we don't get an error about missing
@@ -631,7 +631,7 @@ impl Build {
631631
// Now, update all existing submodules.
632632
build.update_existing_submodules();
633633

634-
build.verbose(|| println!("learning about cargo"));
634+
build.do_if_verbose(|| println!("learning about cargo"));
635635
crate::core::metadata::build(&mut build);
636636
}
637637

src/bootstrap/src/utils/build_stamp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub fn clear_if_dirty(builder: &Builder<'_>, dir: &Path, input: &Path) -> bool {
112112
let stamp = BuildStamp::new(dir);
113113
let mut cleared = false;
114114
if mtime(stamp.path()) < mtime(input) {
115-
builder.verbose(|| println!("Dirty - {}", dir.display()));
115+
builder.do_if_verbose(|| println!("Dirty - {}", dir.display()));
116116
let _ = fs::remove_dir_all(dir);
117117
cleared = true;
118118
} else if stamp.path().exists() {

src/bootstrap/src/utils/cc_detect.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,16 @@ pub fn fill_target_compiler(build: &mut Build, target: TargetSelection) {
137137
build.cxx.insert(target, compiler);
138138
}
139139

140-
build.verbose(|| println!("CC_{} = {:?}", target.triple, build.cc(target)));
141-
build.verbose(|| println!("CFLAGS_{} = {cflags:?}", target.triple));
140+
build.do_if_verbose(|| println!("CC_{} = {:?}", target.triple, build.cc(target)));
141+
build.do_if_verbose(|| println!("CFLAGS_{} = {cflags:?}", target.triple));
142142
if let Ok(cxx) = build.cxx(target) {
143143
let mut cxxflags = build.cc_handled_clags(target, CLang::Cxx);
144144
cxxflags.extend(build.cc_unhandled_cflags(target, GitRepo::Rustc, CLang::Cxx));
145-
build.verbose(|| println!("CXX_{} = {cxx:?}", target.triple));
146-
build.verbose(|| println!("CXXFLAGS_{} = {cxxflags:?}", target.triple));
145+
build.do_if_verbose(|| println!("CXX_{} = {cxx:?}", target.triple));
146+
build.do_if_verbose(|| println!("CXXFLAGS_{} = {cxxflags:?}", target.triple));
147147
}
148148
if let Some(ar) = ar {
149-
build.verbose(|| println!("AR_{} = {ar:?}", target.triple));
149+
build.do_if_verbose(|| println!("AR_{} = {ar:?}", target.triple));
150150
build.ar.insert(target, ar);
151151
}
152152

0 commit comments

Comments
 (0)