Skip to content

Commit d25f64a

Browse files
committed
feat: refactored bootstrap files to use stderr consistently
1 parent bdcb6a9 commit d25f64a

File tree

11 files changed

+40
-40
lines changed

11 files changed

+40
-40
lines changed

src/bootstrap/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ impl StepDescription {
227227

228228
fn is_excluded(&self, builder: &Builder<'_>, pathset: &PathSet) -> bool {
229229
if builder.config.exclude.iter().any(|e| pathset.has(&e.path, e.kind)) {
230-
eprintln!("Skipping {:?} because it is excluded", pathset);
230+
println!("Skipping {:?} because it is excluded", pathset);
231231
return true;
232232
}
233233

src/bootstrap/compile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,7 @@ pub fn stream_cargo(
14261426
cb(msg)
14271427
}
14281428
// If this was informational, just print it out and continue
1429-
Err(_) => println!("{}", line),
1429+
Err(_) => eprintln!("{}", line),
14301430
}
14311431
}
14321432

src/bootstrap/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ impl Config {
766766
{
767767
Ok(table) => table,
768768
Err(err) => {
769-
println!("failed to parse TOML configuration '{}': {}", file.display(), err);
769+
eprintln!("failed to parse TOML configuration '{}': {}", file.display(), err);
770770
process::exit(2);
771771
}
772772
}

src/bootstrap/dist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub fn tmpdir(builder: &Builder<'_>) -> PathBuf {
3737

3838
fn missing_tool(tool_name: &str, skip: bool) {
3939
if skip {
40-
println!("Unable to build {}, skipping dist", tool_name)
40+
eprintln!("Unable to build {}, skipping dist", tool_name)
4141
} else {
4242
panic!("Unable to build {}", tool_name)
4343
}

src/bootstrap/flags.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
365365
}
366366
}
367367
if !pass_sanity_check {
368-
println!("{}\n", subcommand_help);
369-
println!(
368+
eprintln!("{}\n", subcommand_help);
369+
eprintln!(
370370
"Sorry, I couldn't figure out which subcommand you were trying to specify.\n\
371371
You may need to move some options to after the subcommand.\n"
372372
);
@@ -530,7 +530,7 @@ Arguments:
530530
Kind::Build => Subcommand::Build { paths },
531531
Kind::Check => {
532532
if matches.opt_present("all-targets") {
533-
eprintln!(
533+
println!(
534534
"Warning: --all-targets is now on by default and does not need to be passed explicitly."
535535
);
536536
}
@@ -603,7 +603,7 @@ Arguments:
603603
if matches.opt_str("keep-stage").is_some()
604604
|| matches.opt_str("keep-stage-std").is_some()
605605
{
606-
println!("--keep-stage not yet supported for x.py check");
606+
eprintln!("--keep-stage not yet supported for x.py check");
607607
process::exit(1);
608608
}
609609
}

src/bootstrap/format.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub fn format(build: &Build, check: bool, paths: &[PathBuf]) {
9696
entry.split(' ').nth(1).expect("every git status entry should list a path")
9797
});
9898
for untracked_path in untracked_paths {
99-
eprintln!("skip untracked path {} during rustfmt invocations", untracked_path);
99+
println!("skip untracked path {} during rustfmt invocations", untracked_path);
100100
// The leading `/` makes it an exact match against the
101101
// repository root, rather than a glob. Without that, if you
102102
// have `foo.rs` in the repository root it will also match
@@ -105,10 +105,10 @@ pub fn format(build: &Build, check: bool, paths: &[PathBuf]) {
105105
ignore_fmt.add(&format!("!/{}", untracked_path)).expect(&untracked_path);
106106
}
107107
} else {
108-
eprintln!("Not in git tree. Skipping git-aware format checks");
108+
println!("Not in git tree. Skipping git-aware format checks");
109109
}
110110
} else {
111-
eprintln!("Could not find usable git. Skipping git-aware format checks");
111+
println!("Could not find usable git. Skipping git-aware format checks");
112112
}
113113
let ignore_fmt = ignore_fmt.build().unwrap();
114114

src/bootstrap/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,9 +686,9 @@ impl Build {
686686
// Check for postponed failures from `test --no-fail-fast`.
687687
let failures = self.delayed_failures.borrow();
688688
if failures.len() > 0 {
689-
println!("\n{} command(s) did not execute successfully:\n", failures.len());
689+
eprintln!("\n{} command(s) did not execute successfully:\n", failures.len());
690690
for failure in failures.iter() {
691-
println!(" - {}\n", failure);
691+
eprintln!(" - {}\n", failure);
692692
}
693693
process::exit(1);
694694
}

src/bootstrap/native.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ pub(crate) fn maybe_download_ci_llvm(builder: &Builder<'_>) {
138138
let llvm_sha = llvm_sha.trim();
139139

140140
if llvm_sha == "" {
141-
println!("error: could not find commit hash for downloading LLVM");
142-
println!("help: maybe your repository history is too shallow?");
143-
println!("help: consider disabling `download-ci-llvm`");
144-
println!("help: or fetch enough history to include one upstream commit");
141+
eprintln!("error: could not find commit hash for downloading LLVM");
142+
eprintln!("help: maybe your repository history is too shallow?");
143+
eprintln!("help: consider disabling `download-ci-llvm`");
144+
eprintln!("help: or fetch enough history to include one upstream commit");
145145
panic!();
146146
}
147147

src/bootstrap/setup.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ pub fn setup(config: &Config, profile: Profile) {
8585
let path = &config.config;
8686

8787
if path.exists() {
88-
println!(
88+
eprintln!(
8989
"error: you asked `x.py` to setup a new config file, but one already exists at `{}`",
9090
path.display()
9191
);
92-
println!("help: try adding `profile = \"{}\"` at the top of {}", profile, path.display());
93-
println!(
92+
eprintln!("help: try adding `profile = \"{}\"` at the top of {}", profile, path.display());
93+
eprintln!(
9494
"note: this will use the configuration in {}",
9595
profile.include_path(&config.src).display()
9696
);
@@ -115,7 +115,7 @@ pub fn setup(config: &Config, profile: Profile) {
115115
println!();
116116

117117
if !rustup_installed() && profile != Profile::User {
118-
println!("`rustup` is not installed; cannot link `stage1` toolchain");
118+
eprintln!("`rustup` is not installed; cannot link `stage1` toolchain");
119119
} else if stage_dir_exists(&stage_path[..]) {
120120
attempt_toolchain_link(&stage_path[..]);
121121
}
@@ -173,7 +173,7 @@ fn attempt_toolchain_link(stage_path: &str) {
173173
}
174174

175175
if !ensure_stage1_toolchain_placeholder_exists(stage_path) {
176-
println!(
176+
eprintln!(
177177
"Failed to create a template for stage 1 toolchain or confirm that it already exists"
178178
);
179179
return;
@@ -184,8 +184,8 @@ fn attempt_toolchain_link(stage_path: &str) {
184184
"Added `stage1` rustup toolchain; try `cargo +stage1 build` on a separate rust project to run a newly-built toolchain"
185185
);
186186
} else {
187-
println!("`rustup` failed to link stage 1 build to `stage1` toolchain");
188-
println!(
187+
eprintln!("`rustup` failed to link stage 1 build to `stage1` toolchain");
188+
eprintln!(
189189
"To manually link stage 1 build to `stage1` toolchain, run:\n
190190
`rustup toolchain link stage1 {}`",
191191
&stage_path
@@ -292,8 +292,8 @@ pub fn interactive_path() -> io::Result<Profile> {
292292
break match parse_with_abbrev(&input) {
293293
Ok(profile) => profile,
294294
Err(err) => {
295-
println!("error: {}", err);
296-
println!("note: press Ctrl+C to exit");
295+
eprintln!("error: {}", err);
296+
eprintln!("note: press Ctrl+C to exit");
297297
continue;
298298
}
299299
};
@@ -320,8 +320,8 @@ undesirable, simply delete the `pre-push` file from .git/hooks."
320320
"y" | "yes" => true,
321321
"n" | "no" | "" => false,
322322
_ => {
323-
println!("error: unrecognized option '{}'", input.trim());
324-
println!("note: press Ctrl+C to exit");
323+
eprintln!("error: unrecognized option '{}'", input.trim());
324+
eprintln!("note: press Ctrl+C to exit");
325325
continue;
326326
}
327327
};
@@ -337,7 +337,7 @@ undesirable, simply delete the `pre-push` file from .git/hooks."
337337
));
338338
let dst = git.join("hooks").join("pre-push");
339339
match fs::hard_link(src, &dst) {
340-
Err(e) => println!(
340+
Err(e) => eprintln!(
341341
"error: could not create hook {}: do you already have the git hook installed?\n{}",
342342
dst.display(),
343343
e

src/bootstrap/tool.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,43 +152,43 @@ impl Step for ToolBuild {
152152
});
153153

154154
if is_expected && !duplicates.is_empty() {
155-
println!(
155+
eprintln!(
156156
"duplicate artifacts found when compiling a tool, this \
157157
typically means that something was recompiled because \
158158
a transitive dependency has different features activated \
159159
than in a previous build:\n"
160160
);
161-
println!(
161+
eprintln!(
162162
"the following dependencies are duplicated although they \
163163
have the same features enabled:"
164164
);
165165
let (same, different): (Vec<_>, Vec<_>) =
166166
duplicates.into_iter().partition(|(_, cur, prev)| cur.2 == prev.2);
167167
for (id, cur, prev) in same {
168-
println!(" {}", id);
168+
eprintln!(" {}", id);
169169
// same features
170-
println!(" `{}` ({:?})\n `{}` ({:?})", cur.0, cur.1, prev.0, prev.1);
170+
eprintln!(" `{}` ({:?})\n `{}` ({:?})", cur.0, cur.1, prev.0, prev.1);
171171
}
172-
println!("the following dependencies have different features:");
172+
eprintln!("the following dependencies have different features:");
173173
for (id, cur, prev) in different {
174-
println!(" {}", id);
174+
eprintln!(" {}", id);
175175
let cur_features: HashSet<_> = cur.2.into_iter().collect();
176176
let prev_features: HashSet<_> = prev.2.into_iter().collect();
177-
println!(
177+
eprintln!(
178178
" `{}` additionally enabled features {:?} at {:?}",
179179
cur.0,
180180
&cur_features - &prev_features,
181181
cur.1
182182
);
183-
println!(
183+
eprintln!(
184184
" `{}` additionally enabled features {:?} at {:?}",
185185
prev.0,
186186
&prev_features - &cur_features,
187187
prev.1
188188
);
189189
}
190-
println!();
191-
println!(
190+
eprintln!();
191+
eprintln!(
192192
"to fix this you will probably want to edit the local \
193193
src/tools/rustc-workspace-hack/Cargo.toml crate, as \
194194
that will update the dependency graph to ensure that \

src/bootstrap/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ fn dir_up_to_date(src: &Path, threshold: SystemTime) -> bool {
437437
}
438438

439439
fn fail(s: &str) -> ! {
440-
println!("\n\n{}\n\n", s);
440+
eprintln!("\n\n{}\n\n", s);
441441
std::process::exit(1);
442442
}
443443

0 commit comments

Comments
 (0)