Skip to content

Commit 1174dba

Browse files
authored
Rollup merge of #97411 - raiyansayeed:print-stderr-consistently, r=Mark-Simulacrum
Print stderr consistently Solves #96712 I tried to follow what I perceived as the general consensus for error messages in boostrap i.e messages that were .. * resulting from an Err(...) => * literally called as "Error: ...." * by the end of the block scope forced to run a panic! or process::exit with a guaranteed non-zero error code.
2 parents 4254f92 + 392077d commit 1174dba

File tree

9 files changed

+38
-38
lines changed

9 files changed

+38
-38
lines changed

src/bootstrap/builder.rs

+1-1
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/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ impl Config {
765765
{
766766
Ok(table) => table,
767767
Err(err) => {
768-
println!("failed to parse TOML configuration '{}': {}", file.display(), err);
768+
eprintln!("failed to parse TOML configuration '{}': {}", file.display(), err);
769769
process::exit(2);
770770
}
771771
}

src/bootstrap/flags.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
367367
}
368368
}
369369
if !pass_sanity_check {
370-
println!("{}\n", subcommand_help);
371-
println!(
370+
eprintln!("{}\n", subcommand_help);
371+
eprintln!(
372372
"Sorry, I couldn't figure out which subcommand you were trying to specify.\n\
373373
You may need to move some options to after the subcommand.\n"
374374
);
@@ -532,7 +532,7 @@ Arguments:
532532
Kind::Build => Subcommand::Build { paths },
533533
Kind::Check => {
534534
if matches.opt_present("all-targets") {
535-
eprintln!(
535+
println!(
536536
"Warning: --all-targets is now on by default and does not need to be passed explicitly."
537537
);
538538
}
@@ -606,7 +606,7 @@ Arguments:
606606
if matches.opt_str("keep-stage").is_some()
607607
|| matches.opt_str("keep-stage-std").is_some()
608608
{
609-
println!("--keep-stage not yet supported for x.py check");
609+
eprintln!("--keep-stage not yet supported for x.py check");
610610
process::exit(1);
611611
}
612612
}

src/bootstrap/format.rs

+3-3
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -689,9 +689,9 @@ impl Build {
689689
// Check for postponed failures from `test --no-fail-fast`.
690690
let failures = self.delayed_failures.borrow();
691691
if failures.len() > 0 {
692-
println!("\n{} command(s) did not execute successfully:\n", failures.len());
692+
eprintln!("\n{} command(s) did not execute successfully:\n", failures.len());
693693
for failure in failures.iter() {
694-
println!(" - {}\n", failure);
694+
eprintln!(" - {}\n", failure);
695695
}
696696
process::exit(1);
697697
}

src/bootstrap/native.rs

+4-4
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

+12-12
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

+10-10
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ fn dir_up_to_date(src: &Path, threshold: SystemTime) -> bool {
455455
}
456456

457457
fn fail(s: &str) -> ! {
458-
println!("\n\n{}\n\n", s);
458+
eprintln!("\n\n{}\n\n", s);
459459
std::process::exit(1);
460460
}
461461

0 commit comments

Comments
 (0)