Skip to content

Commit b58e611

Browse files
authored
Rollup merge of rust-lang#106314 - jyn514:fix-panic, r=jyn514
Fix panic on `x build --help` Fixes rust-lang#106313. This avoids trying to run `get_help` unless we actually need to see the paths that are available for the subcommand. This originally regressed in rust-lang#106166.
2 parents 88470f3 + 6d2fe52 commit b58e611

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/bootstrap/flags.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -352,32 +352,32 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
352352

353353
// fn usage()
354354
let usage = |exit_code: i32, opts: &Options, verbose: bool, subcommand_help: &str| -> ! {
355-
// We have an unfortunate situation here: some Steps use `builder.in_tree_crates` to determine their paths.
356-
// To determine those crates, we need to run `cargo metadata`, which means we need all submodules to be checked out.
357-
// That takes a while to run, so only do it when paths were explicitly requested, not on all CLI errors.
358-
// `Build::new` won't load submodules for the `setup` command.
359-
let cmd = if verbose {
360-
println!("note: updating submodules before printing available paths");
361-
"build"
362-
} else {
363-
"setup"
364-
};
365-
let config = Config::parse(&[cmd.to_string()]);
366-
let build = Build::new(config);
367-
let paths = Builder::get_help(&build, subcommand);
368-
369355
println!("{}", opts.usage(subcommand_help));
370-
if let Some(s) = paths {
371-
if verbose {
356+
if verbose {
357+
// We have an unfortunate situation here: some Steps use `builder.in_tree_crates` to determine their paths.
358+
// To determine those crates, we need to run `cargo metadata`, which means we need all submodules to be checked out.
359+
// That takes a while to run, so only do it when paths were explicitly requested, not on all CLI errors.
360+
// `Build::new` won't load submodules for the `setup` command.
361+
let cmd = if verbose {
362+
println!("note: updating submodules before printing available paths");
363+
"build"
364+
} else {
365+
"setup"
366+
};
367+
let config = Config::parse(&[cmd.to_string()]);
368+
let build = Build::new(config);
369+
let paths = Builder::get_help(&build, subcommand);
370+
371+
if let Some(s) = paths {
372372
println!("{}", s);
373373
} else {
374-
println!(
375-
"Run `./x.py {} -h -v` to see a list of available paths.",
376-
subcommand.as_str()
377-
);
374+
panic!("No paths available for subcommand `{}`", subcommand.as_str());
378375
}
379-
} else if verbose {
380-
panic!("No paths available for subcommand `{}`", subcommand.as_str());
376+
} else {
377+
println!(
378+
"Run `./x.py {} -h -v` to see a list of available paths.",
379+
subcommand.as_str()
380+
);
381381
}
382382
crate::detail_exit(exit_code);
383383
};

0 commit comments

Comments
 (0)