Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b282774

Browse files
authoredDec 9, 2024
Rollup merge of #134040 - clubby789:bootstrap-eprintln, r=jieyouxu
bootstrap: print{ln}! -> eprint{ln}! (take 2) r? `@jieyouxu` Reland of #133817 with the `print!`s changed as well.
2 parents e0f3db0 + a6c4628 commit b282774

32 files changed

+211
-207
lines changed
 

‎src/bootstrap/src/bin/main.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ fn main() {
4848
err => {
4949
drop(err);
5050
if let Ok(pid) = pid {
51-
println!("WARNING: build directory locked by process {pid}, waiting for lock");
51+
eprintln!("WARNING: build directory locked by process {pid}, waiting for lock");
5252
} else {
53-
println!("WARNING: build directory locked, waiting for lock");
53+
eprintln!("WARNING: build directory locked, waiting for lock");
5454
}
5555
let mut lock = t!(build_lock.write());
5656
t!(lock.write(process::id().to_string().as_ref()));
@@ -70,13 +70,13 @@ fn main() {
7070
// changelog warning, not the `x.py setup` message.
7171
let suggest_setup = config.config.is_none() && !matches!(config.cmd, Subcommand::Setup { .. });
7272
if suggest_setup {
73-
println!("WARNING: you have not made a `config.toml`");
74-
println!(
73+
eprintln!("WARNING: you have not made a `config.toml`");
74+
eprintln!(
7575
"HELP: consider running `./x.py setup` or copying `config.example.toml` by running \
7676
`cp config.example.toml config.toml`"
7777
);
7878
} else if let Some(suggestion) = &changelog_suggestion {
79-
println!("{suggestion}");
79+
eprintln!("{suggestion}");
8080
}
8181

8282
let pre_commit = config.src.join(".git").join("hooks").join("pre-commit");
@@ -86,13 +86,13 @@ fn main() {
8686
Build::new(config).build();
8787

8888
if suggest_setup {
89-
println!("WARNING: you have not made a `config.toml`");
90-
println!(
89+
eprintln!("WARNING: you have not made a `config.toml`");
90+
eprintln!(
9191
"HELP: consider running `./x.py setup` or copying `config.example.toml` by running \
9292
`cp config.example.toml config.toml`"
9393
);
9494
} else if let Some(suggestion) = &changelog_suggestion {
95-
println!("{suggestion}");
95+
eprintln!("{suggestion}");
9696
}
9797

9898
// Give a warning if the pre-commit script is in pre-commit and not pre-push.
@@ -102,14 +102,14 @@ fn main() {
102102
if fs::read_to_string(pre_commit).is_ok_and(|contents| {
103103
contents.contains("https://github.com/rust-lang/rust/issues/77620#issuecomment-705144570")
104104
}) {
105-
println!(
105+
eprintln!(
106106
"WARNING: You have the pre-push script installed to .git/hooks/pre-commit. \
107107
Consider moving it to .git/hooks/pre-push instead, which runs less often."
108108
);
109109
}
110110

111111
if suggest_setup || changelog_suggestion.is_some() {
112-
println!("NOTE: this message was printed twice to make it more likely to be seen");
112+
eprintln!("NOTE: this message was printed twice to make it more likely to be seen");
113113
}
114114

115115
if dump_bootstrap_shims {

‎src/bootstrap/src/bin/rustc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ fn main() {
306306
// should run on success, after this block.
307307
}
308308
if verbose > 0 {
309-
println!("\nDid not run successfully: {status}\n{cmd:?}\n-------------");
309+
eprintln!("\nDid not run successfully: {status}\n{cmd:?}\n-------------");
310310
}
311311

312312
if let Some(mut on_fail) = on_fail {

‎src/bootstrap/src/core/build_steps/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ impl Step for CodegenBackend {
287287
fn run(self, builder: &Builder<'_>) {
288288
// FIXME: remove once https://github.com/rust-lang/rust/issues/112393 is resolved
289289
if builder.build.config.vendor && self.backend == "gcc" {
290-
println!("Skipping checking of `rustc_codegen_gcc` with vendoring enabled.");
290+
eprintln!("Skipping checking of `rustc_codegen_gcc` with vendoring enabled.");
291291
return;
292292
}
293293

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,7 @@ impl Step for Sysroot {
16111611
let sysroot = sysroot_dir(compiler.stage);
16121612

16131613
builder
1614-
.verbose(|| println!("Removing sysroot {} to avoid caching bugs", sysroot.display()));
1614+
.verbose(|| eprintln!("Removing sysroot {} to avoid caching bugs", sysroot.display()));
16151615
let _ = fs::remove_dir_all(&sysroot);
16161616
t!(fs::create_dir_all(&sysroot));
16171617

@@ -1681,7 +1681,7 @@ impl Step for Sysroot {
16811681
return true;
16821682
}
16831683
if !filtered_files.iter().all(|f| f != path.file_name().unwrap()) {
1684-
builder.verbose_than(1, || println!("ignoring {}", path.display()));
1684+
builder.verbose_than(1, || eprintln!("ignoring {}", path.display()));
16851685
false
16861686
} else {
16871687
true
@@ -2240,7 +2240,7 @@ pub fn stream_cargo(
22402240
cargo.arg(arg);
22412241
}
22422242

2243-
builder.verbose(|| println!("running: {cargo:?}"));
2243+
builder.verbose(|| eprintln!("running: {cargo:?}"));
22442244

22452245
if builder.config.dry_run() {
22462246
return true;
@@ -2261,12 +2261,12 @@ pub fn stream_cargo(
22612261
Ok(msg) => {
22622262
if builder.config.json_output {
22632263
// Forward JSON to stdout.
2264-
println!("{line}");
2264+
eprintln!("{line}");
22652265
}
22662266
cb(msg)
22672267
}
22682268
// If this was informational, just print it out and continue
2269-
Err(_) => println!("{line}"),
2269+
Err(_) => eprintln!("{line}"),
22702270
}
22712271
}
22722272

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2080,7 +2080,7 @@ fn maybe_install_llvm(
20802080
{
20812081
let mut cmd = command(llvm_config);
20822082
cmd.arg("--libfiles");
2083-
builder.verbose(|| println!("running {cmd:?}"));
2083+
builder.verbose(|| eprintln!("running {cmd:?}"));
20842084
let files = cmd.run_capture_stdout(builder).stdout();
20852085
let build_llvm_out = &builder.llvm_out(builder.config.build);
20862086
let target_llvm_out = &builder.llvm_out(target);

‎src/bootstrap/src/core/build_steps/format.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ fn print_paths(verb: &str, adjective: Option<&str>, paths: &[String]) {
107107
if let Some(adjective) = adjective { format!("{adjective} ") } else { String::new() };
108108
if len <= 10 {
109109
for path in paths {
110-
println!("fmt: {verb} {adjective}file {path}");
110+
eprintln!("fmt: {verb} {adjective}file {path}");
111111
}
112112
} else {
113-
println!("fmt: {verb} {len} {adjective}files");
113+
eprintln!("fmt: {verb} {len} {adjective}files");
114114
}
115115
}
116116

@@ -199,7 +199,7 @@ pub fn format(build: &Builder<'_>, check: bool, all: bool, paths: &[PathBuf]) {
199199
match get_modified_rs_files(build) {
200200
Ok(Some(files)) => {
201201
if files.is_empty() {
202-
println!("fmt info: No modified files detected for formatting.");
202+
eprintln!("fmt info: No modified files detected for formatting.");
203203
return;
204204
}
205205

‎src/bootstrap/src/core/build_steps/setup.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl Step for Profile {
134134
t!(fs::remove_file(path));
135135
}
136136
_ => {
137-
println!("Exiting.");
137+
eprintln!("Exiting.");
138138
crate::exit!(1);
139139
}
140140
}
@@ -184,15 +184,15 @@ pub fn setup(config: &Config, profile: Profile) {
184184
Profile::Dist => &["dist", "build"],
185185
};
186186

187-
println!();
187+
eprintln!();
188188

189-
println!("To get started, try one of the following commands:");
189+
eprintln!("To get started, try one of the following commands:");
190190
for cmd in suggestions {
191-
println!("- `x.py {cmd}`");
191+
eprintln!("- `x.py {cmd}`");
192192
}
193193

194194
if profile != Profile::Dist {
195-
println!(
195+
eprintln!(
196196
"For more suggestions, see https://rustc-dev-guide.rust-lang.org/building/suggested.html"
197197
);
198198
}
@@ -224,7 +224,7 @@ fn setup_config_toml(path: &PathBuf, profile: Profile, config: &Config) {
224224
t!(fs::write(path, settings));
225225

226226
let include_path = profile.include_path(&config.src);
227-
println!("`x.py` will now use the configuration at {}", include_path.display());
227+
eprintln!("`x.py` will now use the configuration at {}", include_path.display());
228228
}
229229

230230
/// Creates a toolchain link for stage1 using `rustup`
@@ -256,7 +256,7 @@ impl Step for Link {
256256
}
257257

258258
if !rustup_installed(builder) {
259-
println!("WARNING: `rustup` is not installed; Skipping `stage1` toolchain linking.");
259+
eprintln!("WARNING: `rustup` is not installed; Skipping `stage1` toolchain linking.");
260260
return;
261261
}
262262

@@ -296,7 +296,7 @@ fn attempt_toolchain_link(builder: &Builder<'_>, stage_path: &str) {
296296
}
297297

298298
if try_link_toolchain(builder, stage_path) {
299-
println!(
299+
eprintln!(
300300
"Added `stage1` rustup toolchain; try `cargo +stage1 build` on a separate rust project to run a newly-built toolchain"
301301
);
302302
} else {
@@ -321,14 +321,14 @@ fn toolchain_is_linked(builder: &Builder<'_>) -> bool {
321321
return false;
322322
}
323323
// The toolchain has already been linked.
324-
println!(
324+
eprintln!(
325325
"`stage1` toolchain already linked; not attempting to link `stage1` toolchain"
326326
);
327327
}
328328
None => {
329329
// In this case, we don't know if the `stage1` toolchain has been linked;
330330
// but `rustup` failed, so let's not go any further.
331-
println!(
331+
eprintln!(
332332
"`rustup` failed to list current toolchains; not attempting to link `stage1` toolchain"
333333
);
334334
}
@@ -389,12 +389,12 @@ pub fn interactive_path() -> io::Result<Profile> {
389389
input.parse()
390390
}
391391

392-
println!("Welcome to the Rust project! What do you want to do with x.py?");
392+
eprintln!("Welcome to the Rust project! What do you want to do with x.py?");
393393
for ((letter, _), profile) in abbrev_all() {
394-
println!("{}) {}: {}", letter, profile, profile.purpose());
394+
eprintln!("{}) {}: {}", letter, profile, profile.purpose());
395395
}
396396
let template = loop {
397-
print!(
397+
eprint!(
398398
"Please choose one ({}): ",
399399
abbrev_all().map(|((l, _), _)| l).collect::<Vec<_>>().join("/")
400400
);
@@ -428,7 +428,7 @@ enum PromptResult {
428428
fn prompt_user(prompt: &str) -> io::Result<Option<PromptResult>> {
429429
let mut input = String::new();
430430
loop {
431-
print!("{prompt} ");
431+
eprint!("{prompt} ");
432432
io::stdout().flush()?;
433433
input.clear();
434434
io::stdin().read_line(&mut input)?;
@@ -490,15 +490,15 @@ fn install_git_hook_maybe(builder: &Builder<'_>, config: &Config) -> io::Result<
490490
return Ok(());
491491
}
492492

493-
println!(
493+
eprintln!(
494494
"\nRust's CI will automatically fail if it doesn't pass `tidy`, the internal tool for ensuring code quality.
495495
If you'd like, x.py can install a git hook for you that will automatically run `test tidy` before
496496
pushing your code to ensure your code is up to par. If you decide later that this behavior is
497497
undesirable, simply delete the `pre-push` file from .git/hooks."
498498
);
499499

500500
if prompt_user("Would you like to install the git hook?: [y/N]")? != Some(PromptResult::Yes) {
501-
println!("Ok, skipping installation!");
501+
eprintln!("Ok, skipping installation!");
502502
return Ok(());
503503
}
504504
if !hooks_dir.exists() {
@@ -515,7 +515,7 @@ undesirable, simply delete the `pre-push` file from .git/hooks."
515515
);
516516
return Err(e);
517517
}
518-
Ok(_) => println!("Linked `src/etc/pre-push.sh` to `.git/hooks/pre-push`"),
518+
Ok(_) => eprintln!("Linked `src/etc/pre-push.sh` to `.git/hooks/pre-push`"),
519519
};
520520
Ok(())
521521
}
@@ -541,7 +541,7 @@ Select which editor you would like to set up [default: None]: ";
541541

542542
let mut input = String::new();
543543
loop {
544-
print!("{}", prompt_str);
544+
eprint!("{}", prompt_str);
545545
io::stdout().flush()?;
546546
input.clear();
547547
io::stdin().read_line(&mut input)?;
@@ -656,7 +656,7 @@ impl Step for Editor {
656656
if let Some(editor_kind) = editor_kind {
657657
while !t!(create_editor_settings_maybe(config, editor_kind.clone())) {}
658658
} else {
659-
println!("Ok, skipping editor setup!");
659+
eprintln!("Ok, skipping editor setup!");
660660
}
661661
}
662662
Err(e) => eprintln!("Could not determine the editor: {e}"),
@@ -689,7 +689,7 @@ fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Resu
689689
mismatched_settings = Some(false);
690690
}
691691
}
692-
println!(
692+
eprintln!(
693693
"\nx.py can automatically install the recommended `{settings_filename}` file for rustc development"
694694
);
695695

@@ -708,7 +708,7 @@ fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Resu
708708
Some(PromptResult::Yes) => true,
709709
Some(PromptResult::Print) => false,
710710
_ => {
711-
println!("Ok, skipping settings!");
711+
eprintln!("Ok, skipping settings!");
712712
return Ok(true);
713713
}
714714
};
@@ -735,9 +735,9 @@ fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Resu
735735
_ => "Created",
736736
};
737737
fs::write(&settings_path, editor.settings_template())?;
738-
println!("{verb} `{}`", settings_filename);
738+
eprintln!("{verb} `{}`", settings_filename);
739739
} else {
740-
println!("\n{}", editor.settings_template());
740+
eprintln!("\n{}", editor.settings_template());
741741
}
742742
Ok(should_create)
743743
}

‎src/bootstrap/src/core/build_steps/suggest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ pub fn suggest(builder: &Builder<'_>, run: bool) {
6666
build.build();
6767
}
6868
} else {
69-
println!("HELP: consider using the `--run` flag to automatically run suggested tests");
69+
eprintln!("HELP: consider using the `--run` flag to automatically run suggested tests");
7070
}
7171
}

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

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

474-
builder.verbose(|| println!("running: {cargo:?}"));
474+
builder.verbose(|| eprintln!("running: {cargo:?}"));
475475
let stdout = cargo.run_capture_stdout(builder).stdout();
476476
// Output is "<sysroot>\n".
477477
let sysroot = stdout.trim_end();
478-
builder.verbose(|| println!("`cargo miri setup --print-sysroot` said: {sysroot:?}"));
478+
builder.verbose(|| eprintln!("`cargo miri setup --print-sysroot` said: {sysroot:?}"));
479479
PathBuf::from(sysroot)
480480
}
481481
}
@@ -2488,7 +2488,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) ->
24882488
}
24892489
}
24902490

2491-
builder.verbose(|| println!("doc tests for: {}", markdown.display()));
2491+
builder.verbose(|| eprintln!("doc tests for: {}", markdown.display()));
24922492
let mut cmd = builder.rustdoc_cmd(compiler);
24932493
builder.add_rust_test_threads(&mut cmd);
24942494
// allow for unstable options such as new editions

‎src/bootstrap/src/core/builder/cargo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ impl Builder<'_> {
523523

524524
let sysroot_str = sysroot.as_os_str().to_str().expect("sysroot should be UTF-8");
525525
if self.is_verbose() && !matches!(self.config.dry_run, DryRun::SelfCheck) {
526-
println!("using sysroot {sysroot_str}");
526+
eprintln!("using sysroot {sysroot_str}");
527527
}
528528

529529
let mut rustflags = Rustflags::new(target);

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,14 @@ impl StepDescription {
392392
fn is_excluded(&self, builder: &Builder<'_>, pathset: &PathSet) -> bool {
393393
if builder.config.skip.iter().any(|e| pathset.has(e, builder.kind)) {
394394
if !matches!(builder.config.dry_run, DryRun::SelfCheck) {
395-
println!("Skipping {pathset:?} because it is excluded");
395+
eprintln!("Skipping {pathset:?} because it is excluded");
396396
}
397397
return true;
398398
}
399399

400400
if !builder.config.skip.is_empty() && !matches!(builder.config.dry_run, DryRun::SelfCheck) {
401401
builder.verbose(|| {
402-
println!(
402+
eprintln!(
403403
"{:?} not skipped for {:?} -- not in {:?}",
404404
pathset, self.name, builder.config.skip
405405
)
@@ -1437,11 +1437,11 @@ impl<'a> Builder<'a> {
14371437
panic!("{}", out);
14381438
}
14391439
if let Some(out) = self.cache.get(&step) {
1440-
self.verbose_than(1, || println!("{}c {:?}", " ".repeat(stack.len()), step));
1440+
self.verbose_than(1, || eprintln!("{}c {:?}", " ".repeat(stack.len()), step));
14411441

14421442
return out;
14431443
}
1444-
self.verbose_than(1, || println!("{}> {:?}", " ".repeat(stack.len()), step));
1444+
self.verbose_than(1, || eprintln!("{}> {:?}", " ".repeat(stack.len()), step));
14451445
stack.push(Box::new(step.clone()));
14461446
}
14471447

@@ -1462,7 +1462,7 @@ impl<'a> Builder<'a> {
14621462
let step_string = format!("{step:?}");
14631463
let brace_index = step_string.find('{').unwrap_or(0);
14641464
let type_string = type_name::<S>();
1465-
println!(
1465+
eprintln!(
14661466
"[TIMING] {} {} -- {}.{:03}",
14671467
&type_string.strip_prefix("bootstrap::").unwrap_or(type_string),
14681468
&step_string[brace_index..],
@@ -1479,7 +1479,9 @@ impl<'a> Builder<'a> {
14791479
let cur_step = stack.pop().expect("step stack empty");
14801480
assert_eq!(cur_step.downcast_ref(), Some(&step));
14811481
}
1482-
self.verbose_than(1, || println!("{}< {:?}", " ".repeat(self.stack.borrow().len()), step));
1482+
self.verbose_than(1, || {
1483+
eprintln!("{}< {:?}", " ".repeat(self.stack.borrow().len()), step)
1484+
});
14831485
self.cache.put(step, out.clone());
14841486
out
14851487
}

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

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,7 @@ impl Config {
12931293
.map(|change_id| change_id.inner.map(crate::find_recent_config_change_ids))
12941294
{
12951295
if !changes.is_empty() {
1296-
println!(
1296+
eprintln!(
12971297
"WARNING: There have been changes to x.py since you last updated:\n{}",
12981298
crate::human_readable_changes(&changes)
12991299
);
@@ -1559,7 +1559,7 @@ impl Config {
15591559
}
15601560

15611561
if cargo_clippy.is_some() && rustc.is_none() {
1562-
println!(
1562+
eprintln!(
15631563
"WARNING: Using `build.cargo-clippy` without `build.rustc` usually fails due to toolchain conflict."
15641564
);
15651565
}
@@ -1841,7 +1841,7 @@ impl Config {
18411841

18421842
// FIXME: Remove this option at the end of 2024.
18431843
if parallel_compiler.is_some() {
1844-
println!(
1844+
eprintln!(
18451845
"WARNING: The `rust.parallel-compiler` option is deprecated and does nothing. The parallel compiler (with one thread) is now the default"
18461846
);
18471847
}
@@ -1873,7 +1873,7 @@ impl Config {
18731873
if available_backends.contains(&backend) {
18741874
panic!("Invalid value '{s}' for 'rust.codegen-backends'. Instead, please use '{backend}'.");
18751875
} else {
1876-
println!("HELP: '{s}' for 'rust.codegen-backends' might fail. \
1876+
eprintln!("HELP: '{s}' for 'rust.codegen-backends' might fail. \
18771877
Codegen backends are mostly defined without the '{CODEGEN_BACKEND_PREFIX}' prefix. \
18781878
In this case, it would be referred to as '{backend}'.");
18791879
}
@@ -1902,7 +1902,7 @@ impl Config {
19021902
// tests may fail due to using a different channel than the one used by the compiler during tests.
19031903
if let Some(commit) = &config.download_rustc_commit {
19041904
if is_user_configured_rust_channel {
1905-
println!(
1905+
eprintln!(
19061906
"WARNING: `rust.download-rustc` is enabled. The `rust.channel` option will be overridden by the CI rustc's channel."
19071907
);
19081908

@@ -1992,10 +1992,10 @@ impl Config {
19921992

19931993
if config.llvm_from_ci {
19941994
let warn = |option: &str| {
1995-
println!(
1995+
eprintln!(
19961996
"WARNING: `{option}` will only be used on `compiler/rustc_llvm` build, not for the LLVM build."
19971997
);
1998-
println!(
1998+
eprintln!(
19991999
"HELP: To use `{option}` for LLVM builds, set `download-ci-llvm` option to false."
20002000
);
20012001
};
@@ -2014,12 +2014,12 @@ impl Config {
20142014
// if they've chosen a different value.
20152015

20162016
if libzstd.is_some() {
2017-
println!(
2017+
eprintln!(
20182018
"WARNING: when using `download-ci-llvm`, the local `llvm.libzstd` option, \
20192019
like almost all `llvm.*` options, will be ignored and set by the LLVM CI \
20202020
artifacts builder config."
20212021
);
2022-
println!(
2022+
eprintln!(
20232023
"HELP: To use `llvm.libzstd` for LLVM/LLD builds, set `download-ci-llvm` option to false."
20242024
);
20252025
}
@@ -2088,7 +2088,7 @@ impl Config {
20882088
if available_backends.contains(&backend) {
20892089
panic!("Invalid value '{s}' for 'target.{triple}.codegen-backends'. Instead, please use '{backend}'.");
20902090
} else {
2091-
println!("HELP: '{s}' for 'target.{triple}.codegen-backends' might fail. \
2091+
eprintln!("HELP: '{s}' for 'target.{triple}.codegen-backends' might fail. \
20922092
Codegen backends are mostly defined without the '{CODEGEN_BACKEND_PREFIX}' prefix. \
20932093
In this case, it would be referred to as '{backend}'.");
20942094
}
@@ -2304,7 +2304,7 @@ impl Config {
23042304
if self.dry_run() {
23052305
return Ok(());
23062306
}
2307-
self.verbose(|| println!("running: {cmd:?}"));
2307+
self.verbose(|| eprintln!("running: {cmd:?}"));
23082308
build_helper::util::try_run(cmd, self.is_verbose())
23092309
}
23102310

@@ -2479,7 +2479,7 @@ impl Config {
24792479
// This happens when LLVM submodule is updated in CI, we should disable ci-rustc without an error
24802480
// to not break CI. For non-CI environments, we should return an error.
24812481
if CiEnv::is_ci() {
2482-
println!("WARNING: LLVM submodule has changes, `download-rustc` will be disabled.");
2482+
eprintln!("WARNING: LLVM submodule has changes, `download-rustc` will be disabled.");
24832483
return None;
24842484
} else {
24852485
panic!("ERROR: LLVM submodule has changes, `download-rustc` can't be used.");
@@ -2490,8 +2490,8 @@ impl Config {
24902490
let ci_config_toml = match self.get_builder_toml("ci-rustc") {
24912491
Ok(ci_config_toml) => ci_config_toml,
24922492
Err(e) if e.to_string().contains("unknown field") => {
2493-
println!("WARNING: CI rustc has some fields that are no longer supported in bootstrap; download-rustc will be disabled.");
2494-
println!("HELP: Consider rebasing to a newer commit if available.");
2493+
eprintln!("WARNING: CI rustc has some fields that are no longer supported in bootstrap; download-rustc will be disabled.");
2494+
eprintln!("HELP: Consider rebasing to a newer commit if available.");
24952495
return None;
24962496
},
24972497
Err(e) => {
@@ -2516,7 +2516,7 @@ impl Config {
25162516
.is_some_and(|s| s == "1" || s == "true");
25172517

25182518
if disable_ci_rustc_if_incompatible && res.is_err() {
2519-
println!("WARNING: download-rustc is disabled with `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` env.");
2519+
eprintln!("WARNING: download-rustc is disabled with `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` env.");
25202520
return None;
25212521
}
25222522

@@ -2701,7 +2701,7 @@ impl Config {
27012701
return;
27022702
}
27032703

2704-
println!("Updating submodule {relative_path}");
2704+
eprintln!("Updating submodule {relative_path}");
27052705
self.check_run(
27062706
helpers::git(Some(&self.src))
27072707
.run_always()
@@ -2824,7 +2824,7 @@ impl Config {
28242824
Some(StringOrBool::Bool(true)) => false,
28252825
Some(StringOrBool::String(s)) if s == "if-unchanged" => {
28262826
if !self.rust_info.is_managed_git_subrepository() {
2827-
println!(
2827+
eprintln!(
28282828
"ERROR: `download-rustc=if-unchanged` is only compatible with Git managed sources."
28292829
);
28302830
crate::exit!(1);
@@ -2857,10 +2857,10 @@ impl Config {
28572857
if if_unchanged {
28582858
return None;
28592859
}
2860-
println!("ERROR: could not find commit hash for downloading rustc");
2861-
println!("HELP: maybe your repository history is too shallow?");
2862-
println!("HELP: consider setting `rust.download-rustc=false` in config.toml");
2863-
println!("HELP: or fetch enough history to include one upstream commit");
2860+
eprintln!("ERROR: could not find commit hash for downloading rustc");
2861+
eprintln!("HELP: maybe your repository history is too shallow?");
2862+
eprintln!("HELP: consider setting `rust.download-rustc=false` in config.toml");
2863+
eprintln!("HELP: or fetch enough history to include one upstream commit");
28642864
crate::exit!(1);
28652865
}
28662866
};
@@ -2899,7 +2899,7 @@ impl Config {
28992899
let if_unchanged = || {
29002900
if self.rust_info.is_from_tarball() {
29012901
// Git is needed for running "if-unchanged" logic.
2902-
println!(
2902+
eprintln!(
29032903
"WARNING: 'if-unchanged' has no effect on tarball sources; ignoring `download-ci-llvm`."
29042904
);
29052905
return false;
@@ -2948,10 +2948,10 @@ impl Config {
29482948
// Only commits merged by bors will have CI artifacts.
29492949
let commit = get_closest_merge_commit(Some(&self.src), &self.git_config(), &[]).unwrap();
29502950
if commit.is_empty() {
2951-
println!("error: could not find commit hash for downloading components from CI");
2952-
println!("help: maybe your repository history is too shallow?");
2953-
println!("help: consider disabling `{option_name}`");
2954-
println!("help: or fetch enough history to include one upstream commit");
2951+
eprintln!("error: could not find commit hash for downloading components from CI");
2952+
eprintln!("help: maybe your repository history is too shallow?");
2953+
eprintln!("help: consider disabling `{option_name}`");
2954+
eprintln!("help: or fetch enough history to include one upstream commit");
29552955
crate::exit!(1);
29562956
}
29572957

@@ -2963,14 +2963,14 @@ impl Config {
29632963
if has_changes {
29642964
if if_unchanged {
29652965
if self.is_verbose() {
2966-
println!(
2966+
eprintln!(
29672967
"warning: saw changes to one of {modified_paths:?} since {commit}; \
29682968
ignoring `{option_name}`"
29692969
);
29702970
}
29712971
return None;
29722972
}
2973-
println!(
2973+
eprintln!(
29742974
"warning: `{option_name}` is enabled, but there are changes to one of {modified_paths:?}"
29752975
);
29762976
}
@@ -3007,7 +3007,7 @@ pub(crate) fn check_incompatible_options_for_ci_llvm(
30073007
($current:expr, $expected:expr) => {
30083008
if let Some(current) = &$current {
30093009
if Some(current) != $expected.as_ref() {
3010-
println!(
3010+
eprintln!(
30113011
"WARNING: `llvm.{}` has no effect with `llvm.download-ci-llvm`. \
30123012
Current value: {:?}, Expected value(s): {}{:?}",
30133013
stringify!($expected).replace("_", "-"),
@@ -3112,7 +3112,7 @@ fn check_incompatible_options_for_ci_rustc(
31123112
($current:expr, $expected:expr, $config_section:expr) => {
31133113
if let Some(current) = &$current {
31143114
if Some(current) != $expected.as_ref() {
3115-
println!(
3115+
eprintln!(
31163116
"WARNING: `{}` has no effect with `rust.download-rustc`. \
31173117
Current value: {:?}, Expected value(s): {}{:?}",
31183118
format!("{}.{}", $config_section, stringify!($expected).replace("_", "-")),

‎src/bootstrap/src/core/config/flags.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,12 @@ impl Flags {
196196
if let Ok(HelpVerboseOnly { help: true, verbose: 1.., cmd: subcommand }) =
197197
HelpVerboseOnly::try_parse_from(normalize_args(args))
198198
{
199-
println!("NOTE: updating submodules before printing available paths");
199+
eprintln!("NOTE: updating submodules before printing available paths");
200200
let config = Config::parse(Self::parse(&[String::from("build")]));
201201
let build = Build::new(config);
202202
let paths = Builder::get_help(&build, subcommand);
203203
if let Some(s) = paths {
204-
println!("{s}");
204+
eprintln!("{s}");
205205
} else {
206206
panic!("No paths available for subcommand `{}`", subcommand.as_str());
207207
}

‎src/bootstrap/src/core/download.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl Config {
7777
if self.dry_run() && !cmd.run_always {
7878
return true;
7979
}
80-
self.verbose(|| println!("running: {cmd:?}"));
80+
self.verbose(|| eprintln!("running: {cmd:?}"));
8181
check_run(cmd, self.is_verbose())
8282
}
8383

@@ -144,7 +144,7 @@ impl Config {
144144
/// Please see <https://nixos.org/patchelf.html> for more information
145145
fn fix_bin_or_dylib(&self, fname: &Path) {
146146
assert_eq!(SHOULD_FIX_BINS_AND_DYLIBS.get(), Some(&true));
147-
println!("attempting to patch {}", fname.display());
147+
eprintln!("attempting to patch {}", fname.display());
148148

149149
// Only build `.nix-deps` once.
150150
static NIX_DEPS_DIR: OnceLock<PathBuf> = OnceLock::new();
@@ -206,7 +206,7 @@ impl Config {
206206
}
207207

208208
fn download_file(&self, url: &str, dest_path: &Path, help_on_error: &str) {
209-
self.verbose(|| println!("download {url}"));
209+
self.verbose(|| eprintln!("download {url}"));
210210
// Use a temporary file in case we crash while downloading, to avoid a corrupt download in cache/.
211211
let tempfile = self.tempdir().join(dest_path.file_name().unwrap());
212212
// While bootstrap itself only supports http and https downloads, downstream forks might
@@ -226,7 +226,7 @@ impl Config {
226226
}
227227

228228
fn download_http_with_retries(&self, tempfile: &Path, url: &str, help_on_error: &str) {
229-
println!("downloading {url}");
229+
eprintln!("downloading {url}");
230230
// Try curl. If that fails and we are on windows, fallback to PowerShell.
231231
// options should be kept in sync with
232232
// src/bootstrap/src/core/download.rs
@@ -341,7 +341,7 @@ impl Config {
341341
short_path = short_path.strip_prefix(pattern).unwrap_or(short_path);
342342
let dst_path = dst.join(short_path);
343343
self.verbose(|| {
344-
println!("extracting {} to {}", original_path.display(), dst.display())
344+
eprintln!("extracting {} to {}", original_path.display(), dst.display())
345345
});
346346
if !t!(member.unpack_in(dst)) {
347347
panic!("path traversal attack ??");
@@ -365,7 +365,7 @@ impl Config {
365365
pub(crate) fn verify(&self, path: &Path, expected: &str) -> bool {
366366
use sha2::Digest;
367367

368-
self.verbose(|| println!("verifying {}", path.display()));
368+
self.verbose(|| eprintln!("verifying {}", path.display()));
369369

370370
if self.dry_run() {
371371
return false;
@@ -391,7 +391,7 @@ impl Config {
391391
let verified = checksum == expected;
392392

393393
if !verified {
394-
println!(
394+
eprintln!(
395395
"invalid checksum: \n\
396396
found: {checksum}\n\
397397
expected: {expected}",
@@ -421,7 +421,7 @@ enum DownloadSource {
421421
/// Functions that are only ever called once, but named for clarify and to avoid thousand-line functions.
422422
impl Config {
423423
pub(crate) fn download_clippy(&self) -> PathBuf {
424-
self.verbose(|| println!("downloading stage0 clippy artifacts"));
424+
self.verbose(|| eprintln!("downloading stage0 clippy artifacts"));
425425

426426
let date = &self.stage0_metadata.compiler.date;
427427
let version = &self.stage0_metadata.compiler.version;
@@ -518,7 +518,7 @@ impl Config {
518518
}
519519

520520
pub(crate) fn download_ci_rustc(&self, commit: &str) {
521-
self.verbose(|| println!("using downloaded stage2 artifacts from CI (commit {commit})"));
521+
self.verbose(|| eprintln!("using downloaded stage2 artifacts from CI (commit {commit})"));
522522

523523
let version = self.artifact_version_part(commit);
524524
// download-rustc doesn't need its own cargo, it can just use beta's. But it does need the
@@ -539,7 +539,7 @@ impl Config {
539539

540540
#[cfg(not(feature = "bootstrap-self-test"))]
541541
pub(crate) fn download_beta_toolchain(&self) {
542-
self.verbose(|| println!("downloading stage0 beta artifacts"));
542+
self.verbose(|| eprintln!("downloading stage0 beta artifacts"));
543543

544544
let date = &self.stage0_metadata.compiler.date;
545545
let version = &self.stage0_metadata.compiler.version;
@@ -677,7 +677,7 @@ impl Config {
677677
return;
678678
} else {
679679
self.verbose(|| {
680-
println!(
680+
eprintln!(
681681
"ignoring cached file {} due to failed verification",
682682
tarball.display()
683683
)
@@ -776,10 +776,10 @@ download-rustc = false
776776
t!(check_incompatible_options_for_ci_llvm(current_config_toml, ci_config_toml));
777777
}
778778
Err(e) if e.to_string().contains("unknown field") => {
779-
println!(
779+
eprintln!(
780780
"WARNING: CI LLVM has some fields that are no longer supported in bootstrap; download-ci-llvm will be disabled."
781781
);
782-
println!("HELP: Consider rebasing to a newer commit if available.");
782+
eprintln!("HELP: Consider rebasing to a newer commit if available.");
783783
}
784784
Err(e) => {
785785
eprintln!("ERROR: Failed to parse CI LLVM config.toml: {e}");

‎src/bootstrap/src/core/sanity.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,11 @@ than building it.
237237
stage0_supported_target_list.intersection(&missing_targets_hashset).collect();
238238

239239
if !duplicated_targets.is_empty() {
240-
println!(
240+
eprintln!(
241241
"Following targets supported from the stage0 compiler, please remove them from STAGE0_MISSING_TARGETS list."
242242
);
243243
for duplicated_target in duplicated_targets {
244-
println!(" {duplicated_target}");
244+
eprintln!(" {duplicated_target}");
245245
}
246246
std::process::exit(1);
247247
}

‎src/bootstrap/src/lib.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -406,19 +406,19 @@ impl Build {
406406
.unwrap()
407407
.trim();
408408
if local_release.split('.').take(2).eq(version.split('.').take(2)) {
409-
build.verbose(|| println!("auto-detected local-rebuild {local_release}"));
409+
build.verbose(|| eprintln!("auto-detected local-rebuild {local_release}"));
410410
build.local_rebuild = true;
411411
}
412412

413-
build.verbose(|| println!("finding compilers"));
413+
build.verbose(|| eprintln!("finding compilers"));
414414
utils::cc_detect::find(&build);
415415
// When running `setup`, the profile is about to change, so any requirements we have now may
416416
// be different on the next invocation. Don't check for them until the next time x.py is
417417
// run. This is ok because `setup` never runs any build commands, so it won't fail if commands are missing.
418418
//
419419
// Similarly, for `setup` we don't actually need submodules or cargo metadata.
420420
if !matches!(build.config.cmd, Subcommand::Setup { .. }) {
421-
build.verbose(|| println!("running sanity check"));
421+
build.verbose(|| eprintln!("running sanity check"));
422422
crate::core::sanity::check(&mut build);
423423

424424
// Make sure we update these before gathering metadata so we don't get an error about missing
@@ -436,7 +436,7 @@ impl Build {
436436
// Now, update all existing submodules.
437437
build.update_existing_submodules();
438438

439-
build.verbose(|| println!("learning about cargo"));
439+
build.verbose(|| eprintln!("learning about cargo"));
440440
crate::core::metadata::build(&mut build);
441441
}
442442

@@ -605,7 +605,7 @@ impl Build {
605605
let stamp = dir.join(".stamp");
606606
let mut cleared = false;
607607
if mtime(&stamp) < mtime(input) {
608-
self.verbose(|| println!("Dirty - {}", dir.display()));
608+
self.verbose(|| eprintln!("Dirty - {}", dir.display()));
609609
let _ = fs::remove_dir_all(dir);
610610
cleared = true;
611611
} else if stamp.exists() {
@@ -890,7 +890,7 @@ impl Build {
890890
let executed_at = std::panic::Location::caller();
891891

892892
self.verbose(|| {
893-
println!("running: {command:?} (created at {created_at}, executed at {executed_at})")
893+
eprintln!("running: {command:?} (created at {created_at}, executed at {executed_at})")
894894
});
895895

896896
let cmd = command.as_command_mut();
@@ -947,7 +947,7 @@ Executed at: {executed_at}"#,
947947

948948
let fail = |message: &str, output: CommandOutput| -> ! {
949949
if self.is_verbose() {
950-
println!("{message}");
950+
eprintln!("{message}");
951951
} else {
952952
let (stdout, stderr) = (output.stdout_if_present(), output.stderr_if_present());
953953
// If the command captures output, the user would not see any indication that
@@ -957,16 +957,16 @@ Executed at: {executed_at}"#,
957957
if let Some(stdout) =
958958
output.stdout_if_present().take_if(|s| !s.trim().is_empty())
959959
{
960-
println!("STDOUT:\n{stdout}\n");
960+
eprintln!("STDOUT:\n{stdout}\n");
961961
}
962962
if let Some(stderr) =
963963
output.stderr_if_present().take_if(|s| !s.trim().is_empty())
964964
{
965-
println!("STDERR:\n{stderr}\n");
965+
eprintln!("STDERR:\n{stderr}\n");
966966
}
967-
println!("Command {command:?} has failed. Rerun with -v to see more details.");
967+
eprintln!("Command {command:?} has failed. Rerun with -v to see more details.");
968968
} else {
969-
println!("Command has failed. Rerun with -v to see more details.");
969+
eprintln!("Command has failed. Rerun with -v to see more details.");
970970
}
971971
}
972972
exit!(1);
@@ -1011,7 +1011,7 @@ Executed at: {executed_at}"#,
10111011
match self.config.dry_run {
10121012
DryRun::SelfCheck => (),
10131013
DryRun::Disabled | DryRun::UserSelected => {
1014-
println!("{msg}");
1014+
eprintln!("{msg}");
10151015
}
10161016
}
10171017
}
@@ -1666,7 +1666,7 @@ Executed at: {executed_at}"#,
16661666
if self.config.dry_run() {
16671667
return;
16681668
}
1669-
self.verbose_than(1, || println!("Copy/Link {src:?} to {dst:?}"));
1669+
self.verbose_than(1, || eprintln!("Copy/Link {src:?} to {dst:?}"));
16701670
if src == dst {
16711671
return;
16721672
}
@@ -1775,7 +1775,7 @@ Executed at: {executed_at}"#,
17751775
return;
17761776
}
17771777
let dst = dstdir.join(src.file_name().unwrap());
1778-
self.verbose_than(1, || println!("Install {src:?} to {dst:?}"));
1778+
self.verbose_than(1, || eprintln!("Install {src:?} to {dst:?}"));
17791779
t!(fs::create_dir_all(dstdir));
17801780
if !src.exists() {
17811781
panic!("ERROR: File \"{}\" not found!", src.display());

‎src/bootstrap/src/utils/cc_detect.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,15 @@ pub fn find_target(build: &Build, target: TargetSelection) {
155155
build.cxx.borrow_mut().insert(target, compiler);
156156
}
157157

158-
build.verbose(|| println!("CC_{} = {:?}", target.triple, build.cc(target)));
159-
build.verbose(|| println!("CFLAGS_{} = {cflags:?}", target.triple));
158+
build.verbose(|| eprintln!("CC_{} = {:?}", target.triple, build.cc(target)));
159+
build.verbose(|| eprintln!("CFLAGS_{} = {cflags:?}", target.triple));
160160
if let Ok(cxx) = build.cxx(target) {
161161
let cxxflags = build.cflags(target, GitRepo::Rustc, CLang::Cxx);
162-
build.verbose(|| println!("CXX_{} = {cxx:?}", target.triple));
163-
build.verbose(|| println!("CXXFLAGS_{} = {cxxflags:?}", target.triple));
162+
build.verbose(|| eprintln!("CXX_{} = {cxx:?}", target.triple));
163+
build.verbose(|| eprintln!("CXXFLAGS_{} = {cxxflags:?}", target.triple));
164164
}
165165
if let Some(ar) = ar {
166-
build.verbose(|| println!("AR_{} = {ar:?}", target.triple));
166+
build.verbose(|| eprintln!("AR_{} = {ar:?}", target.triple));
167167
build.ar.borrow_mut().insert(target, ar);
168168
}
169169

‎src/bootstrap/src/utils/helpers.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl Drop for TimeIt {
135135
fn drop(&mut self) {
136136
let time = self.1.elapsed();
137137
if !self.0 {
138-
println!("\tfinished in {}.{:03} seconds", time.as_secs(), time.subsec_millis());
138+
eprintln!("\tfinished in {}.{:03} seconds", time.as_secs(), time.subsec_millis());
139139
}
140140
}
141141
}
@@ -267,12 +267,12 @@ pub fn check_run(cmd: &mut BootstrapCommand, print_cmd_on_fail: bool) -> bool {
267267
let status = match cmd.as_command_mut().status() {
268268
Ok(status) => status,
269269
Err(e) => {
270-
println!("failed to execute command: {cmd:?}\nERROR: {e}");
270+
eprintln!("failed to execute command: {cmd:?}\nERROR: {e}");
271271
return false;
272272
}
273273
};
274274
if !status.success() && print_cmd_on_fail {
275-
println!(
275+
eprintln!(
276276
"\n\ncommand did not execute successfully: {cmd:?}\n\
277277
expected success, got: {status}\n\n"
278278
);

‎src/bootstrap/src/utils/metrics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ impl BuildMetrics {
185185
if version.format_version == CURRENT_FORMAT_VERSION {
186186
t!(serde_json::from_slice::<JsonRoot>(&contents)).invocations
187187
} else {
188-
println!(
188+
eprintln!(
189189
"WARNING: overriding existing build/metrics.json, as it's not \
190190
compatible with build metrics format version {CURRENT_FORMAT_VERSION}."
191191
);

‎src/bootstrap/src/utils/render_tests.rs

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn run_tests(builder: &Builder<'_>, cmd: &mut BootstrapCommand, stream: bool) ->
5656
let cmd = cmd.as_command_mut();
5757
cmd.stdout(Stdio::piped());
5858

59-
builder.verbose(|| println!("running: {cmd:?}"));
59+
builder.verbose(|| eprintln!("running: {cmd:?}"));
6060

6161
let mut process = cmd.spawn().unwrap();
6262

@@ -71,7 +71,7 @@ fn run_tests(builder: &Builder<'_>, cmd: &mut BootstrapCommand, stream: bool) ->
7171

7272
let result = process.wait_with_output().unwrap();
7373
if !result.status.success() && builder.is_verbose() {
74-
println!(
74+
eprintln!(
7575
"\n\ncommand did not execute successfully: {cmd:?}\n\
7676
expected success, got: {}",
7777
result.status
@@ -135,7 +135,9 @@ impl<'a> Renderer<'a> {
135135
if self.up_to_date_tests > 0 {
136136
let n = self.up_to_date_tests;
137137
let s = if n > 1 { "s" } else { "" };
138-
println!("help: ignored {n} up-to-date test{s}; use `--force-rerun` to prevent this\n");
138+
eprintln!(
139+
"help: ignored {n} up-to-date test{s}; use `--force-rerun` to prevent this\n"
140+
);
139141
}
140142
}
141143

@@ -185,58 +187,58 @@ impl<'a> Renderer<'a> {
185187
}
186188

187189
fn render_test_outcome_verbose(&self, outcome: Outcome<'_>, test: &TestOutcome) {
188-
print!("test {} ... ", test.name);
189-
self.builder.colored_stdout(|stdout| outcome.write_long(stdout)).unwrap();
190+
eprint!("test {} ... ", test.name);
191+
self.builder.colored_stderr(|stdout| outcome.write_long(stdout)).unwrap();
190192
if let Some(exec_time) = test.exec_time {
191-
print!(" ({exec_time:.2?})");
193+
eprint!(" ({exec_time:.2?})");
192194
}
193-
println!();
195+
eprintln!();
194196
}
195197

196198
fn render_test_outcome_terse(&mut self, outcome: Outcome<'_>, test: &TestOutcome) {
197199
if self.terse_tests_in_line != 0 && self.terse_tests_in_line % TERSE_TESTS_PER_LINE == 0 {
198200
if let Some(total) = self.tests_count {
199201
let total = total.to_string();
200202
let executed = format!("{:>width$}", self.executed_tests - 1, width = total.len());
201-
print!(" {executed}/{total}");
203+
eprint!(" {executed}/{total}");
202204
}
203-
println!();
205+
eprintln!();
204206
self.terse_tests_in_line = 0;
205207
}
206208

207209
self.terse_tests_in_line += 1;
208-
self.builder.colored_stdout(|stdout| outcome.write_short(stdout, &test.name)).unwrap();
210+
self.builder.colored_stderr(|stdout| outcome.write_short(stdout, &test.name)).unwrap();
209211
let _ = std::io::stdout().flush();
210212
}
211213

212214
fn render_suite_outcome(&self, outcome: Outcome<'_>, suite: &SuiteOutcome) {
213215
// The terse output doesn't end with a newline, so we need to add it ourselves.
214216
if !self.builder.config.verbose_tests {
215-
println!();
217+
eprintln!();
216218
}
217219

218220
if !self.failures.is_empty() {
219-
println!("\nfailures:\n");
221+
eprintln!("\nfailures:\n");
220222
for failure in &self.failures {
221223
if failure.stdout.is_some() || failure.message.is_some() {
222-
println!("---- {} stdout ----", failure.name);
224+
eprintln!("---- {} stdout ----", failure.name);
223225
if let Some(stdout) = &failure.stdout {
224-
println!("{stdout}");
226+
eprintln!("{stdout}");
225227
}
226228
if let Some(message) = &failure.message {
227-
println!("NOTE: {message}");
229+
eprintln!("NOTE: {message}");
228230
}
229231
}
230232
}
231233

232-
println!("\nfailures:");
234+
eprintln!("\nfailures:");
233235
for failure in &self.failures {
234-
println!(" {}", failure.name);
236+
eprintln!(" {}", failure.name);
235237
}
236238
}
237239

238240
if !self.benches.is_empty() {
239-
println!("\nbenchmarks:");
241+
eprintln!("\nbenchmarks:");
240242

241243
let mut rows = Vec::new();
242244
for bench in &self.benches {
@@ -251,13 +253,13 @@ impl<'a> Renderer<'a> {
251253
let max_1 = rows.iter().map(|r| r.1.len()).max().unwrap_or(0);
252254
let max_2 = rows.iter().map(|r| r.2.len()).max().unwrap_or(0);
253255
for row in &rows {
254-
println!(" {:<max_0$} {:>max_1$} {:>max_2$}", row.0, row.1, row.2);
256+
eprintln!(" {:<max_0$} {:>max_1$} {:>max_2$}", row.0, row.1, row.2);
255257
}
256258
}
257259

258-
print!("\ntest result: ");
259-
self.builder.colored_stdout(|stdout| outcome.write_long(stdout)).unwrap();
260-
println!(
260+
eprint!("\ntest result: ");
261+
self.builder.colored_stderr(|stdout| outcome.write_long(stdout)).unwrap();
262+
eprintln!(
261263
". {} passed; {} failed; {} ignored; {} measured; {} filtered out{time}\n",
262264
suite.passed,
263265
suite.failed,
@@ -274,7 +276,7 @@ impl<'a> Renderer<'a> {
274276
fn render_message(&mut self, message: Message) {
275277
match message {
276278
Message::Suite(SuiteMessage::Started { test_count }) => {
277-
println!("\nrunning {test_count} tests");
279+
eprintln!("\nrunning {test_count} tests");
278280
self.executed_tests = 0;
279281
self.terse_tests_in_line = 0;
280282
self.tests_count = Some(test_count);
@@ -314,7 +316,7 @@ impl<'a> Renderer<'a> {
314316
self.failures.push(outcome);
315317
}
316318
Message::Test(TestMessage::Timeout { name }) => {
317-
println!("test {name} has been running for a long time");
319+
eprintln!("test {name} has been running for a long time");
318320
}
319321
Message::Test(TestMessage::Started) => {} // Not useful
320322
}

‎src/bootstrap/src/utils/tarball.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ impl<'a> Tarball<'a> {
344344
// For `x install` tarball files aren't needed, so we can speed up the process by not producing them.
345345
let compression_profile = if self.builder.kind == Kind::Install {
346346
self.builder.verbose(|| {
347-
println!("Forcing dist.compression-profile = 'no-op' for `x install`.")
347+
eprintln!("Forcing dist.compression-profile = 'no-op' for `x install`.")
348348
});
349349
// "no-op" indicates that the rust-installer won't produce compressed tarball sources.
350350
"no-op"

‎src/tools/compiletest/src/compute_diff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ where
144144
}
145145

146146
if !wrote_data {
147-
println!("note: diff is identical to nightly rustdoc");
147+
eprintln!("note: diff is identical to nightly rustdoc");
148148
assert!(diff_output.metadata().unwrap().len() == 0);
149149
return false;
150150
} else if verbose {

‎src/tools/compiletest/src/debuggers.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ pub(crate) fn configure_gdb(config: &Config) -> Option<Arc<Config>> {
2020
}
2121

2222
if config.remote_test_client.is_some() && !config.target.contains("android") {
23-
println!(
23+
eprintln!(
2424
"WARNING: debuginfo tests are not available when \
2525
testing with remote"
2626
);
2727
return None;
2828
}
2929

3030
if config.target.contains("android") {
31-
println!(
31+
eprintln!(
3232
"{} debug-info test uses tcp 5039 port.\
3333
please reserve it",
3434
config.target
@@ -50,7 +50,7 @@ pub(crate) fn configure_lldb(config: &Config) -> Option<Arc<Config>> {
5050
config.lldb_python_dir.as_ref()?;
5151

5252
if let Some(350) = config.lldb_version {
53-
println!(
53+
eprintln!(
5454
"WARNING: The used version of LLDB (350) has a \
5555
known issue that breaks debuginfo tests. See \
5656
issue #32520 for more information. Skipping all \

‎src/tools/compiletest/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
188188
let (argv0, args_) = args.split_first().unwrap();
189189
if args.len() == 1 || args[1] == "-h" || args[1] == "--help" {
190190
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
191-
println!("{}", opts.usage(&message));
192-
println!();
191+
eprintln!("{}", opts.usage(&message));
192+
eprintln!();
193193
panic!()
194194
}
195195

@@ -200,8 +200,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
200200

201201
if matches.opt_present("h") || matches.opt_present("help") {
202202
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
203-
println!("{}", opts.usage(&message));
204-
println!();
203+
eprintln!("{}", opts.usage(&message));
204+
eprintln!();
205205
panic!()
206206
}
207207

@@ -508,7 +508,7 @@ pub fn run_tests(config: Arc<Config>) {
508508
// easy to miss which tests failed, and as such fail to reproduce
509509
// the failure locally.
510510

511-
println!(
511+
eprintln!(
512512
"Some tests failed in compiletest suite={}{} mode={} host={} target={}",
513513
config.suite,
514514
config

‎src/tools/compiletest/src/runtest.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub fn run(config: Arc<Config>, testpaths: &TestPaths, revision: Option<&str>) {
131131

132132
if config.verbose {
133133
// We're going to be dumping a lot of info. Start on a new line.
134-
print!("\n\n");
134+
eprintln!("\n");
135135
}
136136
debug!("running {:?}", testpaths.file.display());
137137
let mut props = TestProps::from_file(&testpaths.file, revision, &config);
@@ -353,7 +353,7 @@ impl<'test> TestCx<'test> {
353353
{
354354
self.error(&format!("{} test did not emit an error", self.config.mode));
355355
if self.config.mode == crate::common::Mode::Ui {
356-
println!("note: by default, ui tests are expected not to compile");
356+
eprintln!("note: by default, ui tests are expected not to compile");
357357
}
358358
proc_res.fatal(None, || ());
359359
};
@@ -774,20 +774,20 @@ impl<'test> TestCx<'test> {
774774
unexpected.len(),
775775
not_found.len()
776776
));
777-
println!("status: {}\ncommand: {}\n", proc_res.status, proc_res.cmdline);
777+
eprintln!("status: {}\ncommand: {}\n", proc_res.status, proc_res.cmdline);
778778
if !unexpected.is_empty() {
779-
println!("{}", "--- unexpected errors (from JSON output) ---".green());
779+
eprintln!("{}", "--- unexpected errors (from JSON output) ---".green());
780780
for error in &unexpected {
781-
println!("{}", error.render_for_expected());
781+
eprintln!("{}", error.render_for_expected());
782782
}
783-
println!("{}", "---".green());
783+
eprintln!("{}", "---".green());
784784
}
785785
if !not_found.is_empty() {
786-
println!("{}", "--- not found errors (from test file) ---".red());
786+
eprintln!("{}", "--- not found errors (from test file) ---".red());
787787
for error in &not_found {
788-
println!("{}", error.render_for_expected());
788+
eprintln!("{}", error.render_for_expected());
789789
}
790-
println!("{}", "---\n".red());
790+
eprintln!("{}", "---\n".red());
791791
}
792792
panic!("errors differ from expected");
793793
}
@@ -1876,18 +1876,18 @@ impl<'test> TestCx<'test> {
18761876

18771877
fn maybe_dump_to_stdout(&self, out: &str, err: &str) {
18781878
if self.config.verbose {
1879-
println!("------stdout------------------------------");
1880-
println!("{}", out);
1881-
println!("------stderr------------------------------");
1882-
println!("{}", err);
1883-
println!("------------------------------------------");
1879+
eprintln!("------stdout------------------------------");
1880+
eprintln!("{}", out);
1881+
eprintln!("------stderr------------------------------");
1882+
eprintln!("{}", err);
1883+
eprintln!("------------------------------------------");
18841884
}
18851885
}
18861886

18871887
fn error(&self, err: &str) {
18881888
match self.revision {
1889-
Some(rev) => println!("\nerror in revision `{}`: {}", rev, err),
1890-
None => println!("\nerror: {}", err),
1889+
Some(rev) => eprintln!("\nerror in revision `{}`: {}", rev, err),
1890+
None => eprintln!("\nerror: {}", err),
18911891
}
18921892
}
18931893

@@ -1972,7 +1972,7 @@ impl<'test> TestCx<'test> {
19721972
if !self.config.has_html_tidy {
19731973
return;
19741974
}
1975-
println!("info: generating a diff against nightly rustdoc");
1975+
eprintln!("info: generating a diff against nightly rustdoc");
19761976

19771977
let suffix =
19781978
self.safe_revision().map_or("nightly".into(), |path| path.to_owned() + "-nightly");
@@ -2082,7 +2082,7 @@ impl<'test> TestCx<'test> {
20822082
.output()
20832083
.unwrap();
20842084
assert!(output.status.success());
2085-
println!("{}", String::from_utf8_lossy(&output.stdout));
2085+
eprintln!("{}", String::from_utf8_lossy(&output.stdout));
20862086
eprintln!("{}", String::from_utf8_lossy(&output.stderr));
20872087
} else {
20882088
use colored::Colorize;
@@ -2496,7 +2496,7 @@ impl<'test> TestCx<'test> {
24962496
)"#
24972497
)
24982498
.replace_all(&output, |caps: &Captures<'_>| {
2499-
println!("{}", &caps[0]);
2499+
eprintln!("{}", &caps[0]);
25002500
caps[0].replace(r"\", "/")
25012501
})
25022502
.replace("\r\n", "\n")
@@ -2601,14 +2601,14 @@ impl<'test> TestCx<'test> {
26012601
if let Err(err) = fs::write(&actual_path, &actual) {
26022602
self.fatal(&format!("failed to write {stream} to `{actual_path:?}`: {err}",));
26032603
}
2604-
println!("Saved the actual {stream} to {actual_path:?}");
2604+
eprintln!("Saved the actual {stream} to {actual_path:?}");
26052605

26062606
let expected_path =
26072607
expected_output_path(self.testpaths, self.revision, &self.config.compare_mode, stream);
26082608

26092609
if !self.config.bless {
26102610
if expected.is_empty() {
2611-
println!("normalized {}:\n{}\n", stream, actual);
2611+
eprintln!("normalized {}:\n{}\n", stream, actual);
26122612
} else {
26132613
self.show_diff(
26142614
stream,
@@ -2631,10 +2631,10 @@ impl<'test> TestCx<'test> {
26312631
if let Err(err) = fs::write(&expected_path, &actual) {
26322632
self.fatal(&format!("failed to write {stream} to `{expected_path:?}`: {err}"));
26332633
}
2634-
println!("Blessing the {stream} of {test_name} in {expected_path:?}");
2634+
eprintln!("Blessing the {stream} of {test_name} in {expected_path:?}");
26352635
}
26362636

2637-
println!("\nThe actual {0} differed from the expected {0}.", stream);
2637+
eprintln!("\nThe actual {0} differed from the expected {0}.", stream);
26382638

26392639
if self.config.bless { 0 } else { 1 }
26402640
}
@@ -2783,7 +2783,7 @@ impl<'test> TestCx<'test> {
27832783
fs::create_dir_all(&incremental_dir).unwrap();
27842784

27852785
if self.config.verbose {
2786-
println!("init_incremental_test: incremental_dir={}", incremental_dir.display());
2786+
eprintln!("init_incremental_test: incremental_dir={}", incremental_dir.display());
27872787
}
27882788
}
27892789

@@ -2841,7 +2841,7 @@ impl ProcRes {
28412841
}
28422842
}
28432843

2844-
println!(
2844+
eprintln!(
28452845
"status: {}\ncommand: {}\n{}\n{}\n",
28462846
self.status,
28472847
self.cmdline,
@@ -2852,7 +2852,7 @@ impl ProcRes {
28522852

28532853
pub fn fatal(&self, err: Option<&str>, on_failure: impl FnOnce()) -> ! {
28542854
if let Some(e) = err {
2855-
println!("\nerror: {}", e);
2855+
eprintln!("\nerror: {}", e);
28562856
}
28572857
self.print_info();
28582858
on_failure();

‎src/tools/compiletest/src/runtest/codegen_units.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ impl TestCx<'_> {
6464
if !missing.is_empty() {
6565
missing.sort();
6666

67-
println!("\nThese items should have been contained but were not:\n");
67+
eprintln!("\nThese items should have been contained but were not:\n");
6868

6969
for item in &missing {
70-
println!("{}", item);
70+
eprintln!("{}", item);
7171
}
7272

73-
println!("\n");
73+
eprintln!("\n");
7474
}
7575

7676
if !unexpected.is_empty() {
@@ -80,24 +80,24 @@ impl TestCx<'_> {
8080
sorted
8181
};
8282

83-
println!("\nThese items were contained but should not have been:\n");
83+
eprintln!("\nThese items were contained but should not have been:\n");
8484

8585
for item in sorted {
86-
println!("{}", item);
86+
eprintln!("{}", item);
8787
}
8888

89-
println!("\n");
89+
eprintln!("\n");
9090
}
9191

9292
if !wrong_cgus.is_empty() {
9393
wrong_cgus.sort_by_key(|pair| pair.0.name.clone());
94-
println!("\nThe following items were assigned to wrong codegen units:\n");
94+
eprintln!("\nThe following items were assigned to wrong codegen units:\n");
9595

9696
for &(ref expected_item, ref actual_item) in &wrong_cgus {
97-
println!("{}", expected_item.name);
98-
println!(" expected: {}", codegen_units_to_str(&expected_item.codegen_units));
99-
println!(" actual: {}", codegen_units_to_str(&actual_item.codegen_units));
100-
println!();
97+
eprintln!("{}", expected_item.name);
98+
eprintln!(" expected: {}", codegen_units_to_str(&expected_item.codegen_units));
99+
eprintln!(" actual: {}", codegen_units_to_str(&actual_item.codegen_units));
100+
eprintln!();
101101
}
102102
}
103103

‎src/tools/compiletest/src/runtest/debuginfo.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl TestCx<'_> {
260260
cmdline,
261261
};
262262
if adb.kill().is_err() {
263-
println!("Adb process is already finished.");
263+
eprintln!("Adb process is already finished.");
264264
}
265265
} else {
266266
let rust_src_root =
@@ -275,7 +275,7 @@ impl TestCx<'_> {
275275

276276
match self.config.gdb_version {
277277
Some(version) => {
278-
println!("NOTE: compiletest thinks it is using GDB version {}", version);
278+
eprintln!("NOTE: compiletest thinks it is using GDB version {}", version);
279279

280280
if version > extract_gdb_version("7.4").unwrap() {
281281
// Add the directory containing the pretty printers to
@@ -297,7 +297,7 @@ impl TestCx<'_> {
297297
}
298298
}
299299
_ => {
300-
println!(
300+
eprintln!(
301301
"NOTE: compiletest does not know which version of \
302302
GDB it is using"
303303
);
@@ -392,10 +392,10 @@ impl TestCx<'_> {
392392

393393
match self.config.lldb_version {
394394
Some(ref version) => {
395-
println!("NOTE: compiletest thinks it is using LLDB version {}", version);
395+
eprintln!("NOTE: compiletest thinks it is using LLDB version {}", version);
396396
}
397397
_ => {
398-
println!(
398+
eprintln!(
399399
"NOTE: compiletest does not know which version of \
400400
LLDB it is using"
401401
);

‎src/tools/compiletest/src/runtest/incremental.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl TestCx<'_> {
3030
assert!(incremental_dir.exists(), "init_incremental_test failed to create incremental dir");
3131

3232
if self.config.verbose {
33-
print!("revision={:?} props={:#?}", revision, self.props);
33+
eprint!("revision={:?} props={:#?}", revision, self.props);
3434
}
3535

3636
if revision.starts_with("cpass") {

‎src/tools/compiletest/src/runtest/mir_opt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl TestCx<'_> {
8989
}
9090
let expected_string = fs::read_to_string(&expected_file).unwrap();
9191
if dumped_string != expected_string {
92-
print!("{}", write_diff(&expected_string, &dumped_string, 3));
92+
eprint!("{}", write_diff(&expected_string, &dumped_string, 3));
9393
panic!(
9494
"Actual MIR output differs from expected MIR output {}",
9595
expected_file.display()

‎src/tools/compiletest/src/runtest/rustdoc_json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl TestCx<'_> {
2929

3030
if !res.status.success() {
3131
self.fatal_proc_rec_with_ctx("jsondocck failed!", &res, |_| {
32-
println!("Rustdoc Output:");
32+
eprintln!("Rustdoc Output:");
3333
proc_res.print_info();
3434
})
3535
}

‎src/tools/compiletest/src/runtest/ui.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ impl TestCx<'_> {
109109
}
110110

111111
if errors > 0 {
112-
println!("To update references, rerun the tests and pass the `--bless` flag");
112+
eprintln!("To update references, rerun the tests and pass the `--bless` flag");
113113
let relative_path_to_file =
114114
self.testpaths.relative_dir.join(self.testpaths.file.file_name().unwrap());
115-
println!(
115+
eprintln!(
116116
"To only update this specific test, also pass `--test-args {}`",
117117
relative_path_to_file.display(),
118118
);

‎src/tools/compiletest/src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn path_div() -> &'static str {
3030
pub fn logv(config: &Config, s: String) {
3131
debug!("{}", s);
3232
if config.verbose {
33-
println!("{}", s);
33+
eprintln!("{}", s);
3434
}
3535
}
3636

0 commit comments

Comments
 (0)
Please sign in to comment.