Rollup merge of #106314 - jyn514:fix-panic, r=jyn514
Fix panic on `x build --help` Fixes https://github.com/rust-lang/rust/issues/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 https://github.com/rust-lang/rust/pull/106166.
This commit is contained in:
commit
7f930b4a54
@ -352,6 +352,8 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
|
|||||||
|
|
||||||
// fn usage()
|
// fn usage()
|
||||||
let usage = |exit_code: i32, opts: &Options, verbose: bool, subcommand_help: &str| -> ! {
|
let usage = |exit_code: i32, opts: &Options, verbose: bool, subcommand_help: &str| -> ! {
|
||||||
|
println!("{}", opts.usage(subcommand_help));
|
||||||
|
if verbose {
|
||||||
// We have an unfortunate situation here: some Steps use `builder.in_tree_crates` to determine their paths.
|
// We have an unfortunate situation here: some Steps use `builder.in_tree_crates` to determine their paths.
|
||||||
// To determine those crates, we need to run `cargo metadata`, which means we need all submodules to be checked out.
|
// To determine those crates, we need to run `cargo metadata`, which means we need all submodules to be checked out.
|
||||||
// That takes a while to run, so only do it when paths were explicitly requested, not on all CLI errors.
|
// That takes a while to run, so only do it when paths were explicitly requested, not on all CLI errors.
|
||||||
@ -366,19 +368,17 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
|
|||||||
let build = Build::new(config);
|
let build = Build::new(config);
|
||||||
let paths = Builder::get_help(&build, subcommand);
|
let paths = Builder::get_help(&build, subcommand);
|
||||||
|
|
||||||
println!("{}", opts.usage(subcommand_help));
|
|
||||||
if let Some(s) = paths {
|
if let Some(s) = paths {
|
||||||
if verbose {
|
|
||||||
println!("{}", s);
|
println!("{}", s);
|
||||||
|
} else {
|
||||||
|
panic!("No paths available for subcommand `{}`", subcommand.as_str());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
println!(
|
println!(
|
||||||
"Run `./x.py {} -h -v` to see a list of available paths.",
|
"Run `./x.py {} -h -v` to see a list of available paths.",
|
||||||
subcommand.as_str()
|
subcommand.as_str()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if verbose {
|
|
||||||
panic!("No paths available for subcommand `{}`", subcommand.as_str());
|
|
||||||
}
|
|
||||||
crate::detail_exit(exit_code);
|
crate::detail_exit(exit_code);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user