Skip to content

Commit 5cfe2a8

Browse files
Store verbosity on Build
Prevents accidental mistakes in not using the right verbosity by going to only config or flags.
1 parent 1561b0c commit 5cfe2a8

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

src/bootstrap/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ pub fn compiletest(build: &Build,
249249

250250
cmd.args(&build.flags.cmd.test_args());
251251

252-
if build.config.verbose() || build.flags.verbose() {
252+
if build.is_verbose() {
253253
cmd.arg("--verbose");
254254
}
255255

src/bootstrap/flags.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@ pub struct Flags {
4141
pub incremental: bool,
4242
}
4343

44-
impl Flags {
45-
pub fn verbose(&self) -> bool {
46-
self.verbose > 0
47-
}
48-
49-
pub fn very_verbose(&self) -> bool {
50-
self.verbose > 1
51-
}
52-
}
53-
5444
pub enum Subcommand {
5545
Build {
5646
paths: Vec<PathBuf>,

src/bootstrap/lib.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ pub struct Build {
168168
rls_info: channel::GitInfo,
169169
local_rebuild: bool,
170170
fail_fast: bool,
171+
verbosity: usize,
171172

172173
// Stage 0 (downloaded) compiler and cargo or their local rust equivalents.
173174
initial_rustc: PathBuf,
@@ -247,6 +248,7 @@ impl Build {
247248
initial_cargo: config.initial_cargo.clone(),
248249
local_rebuild: config.local_rebuild,
249250
fail_fast: flags.cmd.fail_fast(),
251+
verbosity: cmp::max(flags.verbose, config.verbose),
250252

251253
flags: flags,
252254
config: config,
@@ -428,8 +430,7 @@ impl Build {
428430
cargo.env("RUSTC_ON_FAIL", on_fail);
429431
}
430432

431-
let verbose = cmp::max(self.config.verbose, self.flags.verbose);
432-
cargo.env("RUSTC_VERBOSE", format!("{}", verbose));
433+
cargo.env("RUSTC_VERBOSE", format!("{}", self.verbosity));
433434

434435
// Specify some various options for build scripts used throughout
435436
// the build.
@@ -467,7 +468,7 @@ impl Build {
467468
// FIXME: should update code to not require this env var
468469
cargo.env("CFG_COMPILER_HOST_TRIPLE", target);
469470

470-
if self.config.verbose() || self.flags.verbose() {
471+
if self.is_verbose() {
471472
cargo.arg("-v");
472473
}
473474
// FIXME: cargo bench does not accept `--release`
@@ -779,9 +780,17 @@ impl Build {
779780
try_run_suppressed(cmd)
780781
}
781782

783+
pub fn is_verbose(&self) -> bool {
784+
self.verbosity > 0
785+
}
786+
787+
pub fn is_very_verbose(&self) -> bool {
788+
self.verbosity > 1
789+
}
790+
782791
/// Prints a message if this build is configured in verbose mode.
783792
fn verbose(&self, msg: &str) {
784-
if self.flags.verbose() || self.config.verbose() {
793+
if self.is_verbose() {
785794
println!("{}", msg);
786795
}
787796
}

0 commit comments

Comments
 (0)