1
Fork 0

feat: refactored bootstrap files to use stderr consistently

This commit is contained in:
Raiyan 2022-05-25 22:01:55 -04:00
parent bdcb6a99e8
commit d25f64ae99
11 changed files with 40 additions and 40 deletions

View file

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

View file

@ -1426,7 +1426,7 @@ pub fn stream_cargo(
cb(msg) cb(msg)
} }
// If this was informational, just print it out and continue // If this was informational, just print it out and continue
Err(_) => println!("{}", line), Err(_) => eprintln!("{}", line),
} }
} }

View file

@ -766,7 +766,7 @@ impl Config {
{ {
Ok(table) => table, Ok(table) => table,
Err(err) => { Err(err) => {
println!("failed to parse TOML configuration '{}': {}", file.display(), err); eprintln!("failed to parse TOML configuration '{}': {}", file.display(), err);
process::exit(2); process::exit(2);
} }
} }

View file

@ -37,7 +37,7 @@ pub fn tmpdir(builder: &Builder<'_>) -> PathBuf {
fn missing_tool(tool_name: &str, skip: bool) { fn missing_tool(tool_name: &str, skip: bool) {
if skip { if skip {
println!("Unable to build {}, skipping dist", tool_name) eprintln!("Unable to build {}, skipping dist", tool_name)
} else { } else {
panic!("Unable to build {}", tool_name) panic!("Unable to build {}", tool_name)
} }

View file

@ -365,8 +365,8 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
} }
} }
if !pass_sanity_check { if !pass_sanity_check {
println!("{}\n", subcommand_help); eprintln!("{}\n", subcommand_help);
println!( eprintln!(
"Sorry, I couldn't figure out which subcommand you were trying to specify.\n\ "Sorry, I couldn't figure out which subcommand you were trying to specify.\n\
You may need to move some options to after the subcommand.\n" You may need to move some options to after the subcommand.\n"
); );
@ -530,7 +530,7 @@ Arguments:
Kind::Build => Subcommand::Build { paths }, Kind::Build => Subcommand::Build { paths },
Kind::Check => { Kind::Check => {
if matches.opt_present("all-targets") { if matches.opt_present("all-targets") {
eprintln!( println!(
"Warning: --all-targets is now on by default and does not need to be passed explicitly." "Warning: --all-targets is now on by default and does not need to be passed explicitly."
); );
} }
@ -603,7 +603,7 @@ Arguments:
if matches.opt_str("keep-stage").is_some() if matches.opt_str("keep-stage").is_some()
|| matches.opt_str("keep-stage-std").is_some() || matches.opt_str("keep-stage-std").is_some()
{ {
println!("--keep-stage not yet supported for x.py check"); eprintln!("--keep-stage not yet supported for x.py check");
process::exit(1); process::exit(1);
} }
} }

View file

@ -96,7 +96,7 @@ pub fn format(build: &Build, check: bool, paths: &[PathBuf]) {
entry.split(' ').nth(1).expect("every git status entry should list a path") entry.split(' ').nth(1).expect("every git status entry should list a path")
}); });
for untracked_path in untracked_paths { for untracked_path in untracked_paths {
eprintln!("skip untracked path {} during rustfmt invocations", untracked_path); println!("skip untracked path {} during rustfmt invocations", untracked_path);
// The leading `/` makes it an exact match against the // The leading `/` makes it an exact match against the
// repository root, rather than a glob. Without that, if you // repository root, rather than a glob. Without that, if you
// have `foo.rs` in the repository root it will also match // have `foo.rs` in the repository root it will also match
@ -105,10 +105,10 @@ pub fn format(build: &Build, check: bool, paths: &[PathBuf]) {
ignore_fmt.add(&format!("!/{}", untracked_path)).expect(&untracked_path); ignore_fmt.add(&format!("!/{}", untracked_path)).expect(&untracked_path);
} }
} else { } else {
eprintln!("Not in git tree. Skipping git-aware format checks"); println!("Not in git tree. Skipping git-aware format checks");
} }
} else { } else {
eprintln!("Could not find usable git. Skipping git-aware format checks"); println!("Could not find usable git. Skipping git-aware format checks");
} }
let ignore_fmt = ignore_fmt.build().unwrap(); let ignore_fmt = ignore_fmt.build().unwrap();

View file

@ -686,9 +686,9 @@ impl Build {
// Check for postponed failures from `test --no-fail-fast`. // Check for postponed failures from `test --no-fail-fast`.
let failures = self.delayed_failures.borrow(); let failures = self.delayed_failures.borrow();
if failures.len() > 0 { if failures.len() > 0 {
println!("\n{} command(s) did not execute successfully:\n", failures.len()); eprintln!("\n{} command(s) did not execute successfully:\n", failures.len());
for failure in failures.iter() { for failure in failures.iter() {
println!(" - {}\n", failure); eprintln!(" - {}\n", failure);
} }
process::exit(1); process::exit(1);
} }

View file

@ -138,10 +138,10 @@ pub(crate) fn maybe_download_ci_llvm(builder: &Builder<'_>) {
let llvm_sha = llvm_sha.trim(); let llvm_sha = llvm_sha.trim();
if llvm_sha == "" { if llvm_sha == "" {
println!("error: could not find commit hash for downloading LLVM"); eprintln!("error: could not find commit hash for downloading LLVM");
println!("help: maybe your repository history is too shallow?"); eprintln!("help: maybe your repository history is too shallow?");
println!("help: consider disabling `download-ci-llvm`"); eprintln!("help: consider disabling `download-ci-llvm`");
println!("help: or fetch enough history to include one upstream commit"); eprintln!("help: or fetch enough history to include one upstream commit");
panic!(); panic!();
} }

View file

@ -85,12 +85,12 @@ pub fn setup(config: &Config, profile: Profile) {
let path = &config.config; let path = &config.config;
if path.exists() { if path.exists() {
println!( eprintln!(
"error: you asked `x.py` to setup a new config file, but one already exists at `{}`", "error: you asked `x.py` to setup a new config file, but one already exists at `{}`",
path.display() path.display()
); );
println!("help: try adding `profile = \"{}\"` at the top of {}", profile, path.display()); eprintln!("help: try adding `profile = \"{}\"` at the top of {}", profile, path.display());
println!( eprintln!(
"note: this will use the configuration in {}", "note: this will use the configuration in {}",
profile.include_path(&config.src).display() profile.include_path(&config.src).display()
); );
@ -115,7 +115,7 @@ pub fn setup(config: &Config, profile: Profile) {
println!(); println!();
if !rustup_installed() && profile != Profile::User { if !rustup_installed() && profile != Profile::User {
println!("`rustup` is not installed; cannot link `stage1` toolchain"); eprintln!("`rustup` is not installed; cannot link `stage1` toolchain");
} else if stage_dir_exists(&stage_path[..]) { } else if stage_dir_exists(&stage_path[..]) {
attempt_toolchain_link(&stage_path[..]); attempt_toolchain_link(&stage_path[..]);
} }
@ -173,7 +173,7 @@ fn attempt_toolchain_link(stage_path: &str) {
} }
if !ensure_stage1_toolchain_placeholder_exists(stage_path) { if !ensure_stage1_toolchain_placeholder_exists(stage_path) {
println!( eprintln!(
"Failed to create a template for stage 1 toolchain or confirm that it already exists" "Failed to create a template for stage 1 toolchain or confirm that it already exists"
); );
return; return;
@ -184,8 +184,8 @@ fn attempt_toolchain_link(stage_path: &str) {
"Added `stage1` rustup toolchain; try `cargo +stage1 build` on a separate rust project to run a newly-built toolchain" "Added `stage1` rustup toolchain; try `cargo +stage1 build` on a separate rust project to run a newly-built toolchain"
); );
} else { } else {
println!("`rustup` failed to link stage 1 build to `stage1` toolchain"); eprintln!("`rustup` failed to link stage 1 build to `stage1` toolchain");
println!( eprintln!(
"To manually link stage 1 build to `stage1` toolchain, run:\n "To manually link stage 1 build to `stage1` toolchain, run:\n
`rustup toolchain link stage1 {}`", `rustup toolchain link stage1 {}`",
&stage_path &stage_path
@ -292,8 +292,8 @@ pub fn interactive_path() -> io::Result<Profile> {
break match parse_with_abbrev(&input) { break match parse_with_abbrev(&input) {
Ok(profile) => profile, Ok(profile) => profile,
Err(err) => { Err(err) => {
println!("error: {}", err); eprintln!("error: {}", err);
println!("note: press Ctrl+C to exit"); eprintln!("note: press Ctrl+C to exit");
continue; continue;
} }
}; };
@ -320,8 +320,8 @@ undesirable, simply delete the `pre-push` file from .git/hooks."
"y" | "yes" => true, "y" | "yes" => true,
"n" | "no" | "" => false, "n" | "no" | "" => false,
_ => { _ => {
println!("error: unrecognized option '{}'", input.trim()); eprintln!("error: unrecognized option '{}'", input.trim());
println!("note: press Ctrl+C to exit"); eprintln!("note: press Ctrl+C to exit");
continue; continue;
} }
}; };
@ -337,7 +337,7 @@ undesirable, simply delete the `pre-push` file from .git/hooks."
)); ));
let dst = git.join("hooks").join("pre-push"); let dst = git.join("hooks").join("pre-push");
match fs::hard_link(src, &dst) { match fs::hard_link(src, &dst) {
Err(e) => println!( Err(e) => eprintln!(
"error: could not create hook {}: do you already have the git hook installed?\n{}", "error: could not create hook {}: do you already have the git hook installed?\n{}",
dst.display(), dst.display(),
e e

View file

@ -152,43 +152,43 @@ impl Step for ToolBuild {
}); });
if is_expected && !duplicates.is_empty() { if is_expected && !duplicates.is_empty() {
println!( eprintln!(
"duplicate artifacts found when compiling a tool, this \ "duplicate artifacts found when compiling a tool, this \
typically means that something was recompiled because \ typically means that something was recompiled because \
a transitive dependency has different features activated \ a transitive dependency has different features activated \
than in a previous build:\n" than in a previous build:\n"
); );
println!( eprintln!(
"the following dependencies are duplicated although they \ "the following dependencies are duplicated although they \
have the same features enabled:" have the same features enabled:"
); );
let (same, different): (Vec<_>, Vec<_>) = let (same, different): (Vec<_>, Vec<_>) =
duplicates.into_iter().partition(|(_, cur, prev)| cur.2 == prev.2); duplicates.into_iter().partition(|(_, cur, prev)| cur.2 == prev.2);
for (id, cur, prev) in same { for (id, cur, prev) in same {
println!(" {}", id); eprintln!(" {}", id);
// same features // same features
println!(" `{}` ({:?})\n `{}` ({:?})", cur.0, cur.1, prev.0, prev.1); eprintln!(" `{}` ({:?})\n `{}` ({:?})", cur.0, cur.1, prev.0, prev.1);
} }
println!("the following dependencies have different features:"); eprintln!("the following dependencies have different features:");
for (id, cur, prev) in different { for (id, cur, prev) in different {
println!(" {}", id); eprintln!(" {}", id);
let cur_features: HashSet<_> = cur.2.into_iter().collect(); let cur_features: HashSet<_> = cur.2.into_iter().collect();
let prev_features: HashSet<_> = prev.2.into_iter().collect(); let prev_features: HashSet<_> = prev.2.into_iter().collect();
println!( eprintln!(
" `{}` additionally enabled features {:?} at {:?}", " `{}` additionally enabled features {:?} at {:?}",
cur.0, cur.0,
&cur_features - &prev_features, &cur_features - &prev_features,
cur.1 cur.1
); );
println!( eprintln!(
" `{}` additionally enabled features {:?} at {:?}", " `{}` additionally enabled features {:?} at {:?}",
prev.0, prev.0,
&prev_features - &cur_features, &prev_features - &cur_features,
prev.1 prev.1
); );
} }
println!(); eprintln!();
println!( eprintln!(
"to fix this you will probably want to edit the local \ "to fix this you will probably want to edit the local \
src/tools/rustc-workspace-hack/Cargo.toml crate, as \ src/tools/rustc-workspace-hack/Cargo.toml crate, as \
that will update the dependency graph to ensure that \ that will update the dependency graph to ensure that \

View file

@ -437,7 +437,7 @@ fn dir_up_to_date(src: &Path, threshold: SystemTime) -> bool {
} }
fn fail(s: &str) -> ! { fn fail(s: &str) -> ! {
println!("\n\n{}\n\n", s); eprintln!("\n\n{}\n\n", s);
std::process::exit(1); std::process::exit(1);
} }