Fix rustdoc help message when no args are passed

This commit is contained in:
bjorn3 2024-03-26 10:27:19 +00:00
parent dc6595ddbc
commit ad1886a5f0
3 changed files with 13 additions and 9 deletions

View File

@ -26,9 +26,10 @@ fn main() {
codegen_backend_arg.push(cg_clif_dylib_path); codegen_backend_arg.push(cg_clif_dylib_path);
args.push(codegen_backend_arg); args.push(codegen_backend_arg);
} }
if !passed_args.iter().any(|arg| { if !passed_args
arg == "--sysroot" || arg.to_str().is_some_and(|s| s.starts_with("--sysroot=")) .iter()
}) { .any(|arg| arg == "--sysroot" || arg.to_str().is_some_and(|s| s.starts_with("--sysroot=")))
{
args.push(OsString::from("--sysroot")); args.push(OsString::from("--sysroot"));
args.push(OsString::from(sysroot.to_str().unwrap())); args.push(OsString::from(sysroot.to_str().unwrap()));
} }

View File

@ -26,12 +26,18 @@ fn main() {
codegen_backend_arg.push(cg_clif_dylib_path); codegen_backend_arg.push(cg_clif_dylib_path);
args.push(codegen_backend_arg); args.push(codegen_backend_arg);
} }
if !passed_args.iter().any(|arg| { if !passed_args
arg == "--sysroot" || arg.to_str().is_some_and(|s| s.starts_with("--sysroot=")) .iter()
}) { .any(|arg| arg == "--sysroot" || arg.to_str().is_some_and(|s| s.starts_with("--sysroot=")))
{
args.push(OsString::from("--sysroot")); args.push(OsString::from("--sysroot"));
args.push(OsString::from(sysroot.to_str().unwrap())); args.push(OsString::from(sysroot.to_str().unwrap()));
} }
if passed_args.is_empty() {
// Don't pass any arguments when the user didn't pass any arguments
// either to ensure the help message is shown.
args.clear();
}
args.extend(passed_args); args.extend(passed_args);
let rustdoc = if let Some(rustdoc) = option_env!("RUSTDOC") { let rustdoc = if let Some(rustdoc) = option_env!("RUSTDOC") {

View File

@ -99,9 +99,6 @@ rm tests/ui/mir/mir_raw_fat_ptr.rs # same
rm tests/ui/consts/issue-33537.rs # same rm tests/ui/consts/issue-33537.rs # same
rm tests/ui/consts/const-mut-refs-crate.rs # same rm tests/ui/consts/const-mut-refs-crate.rs # same
# rustdoc-clif passes extra args, suppressing the help message when no args are passed
rm -r tests/run-make/issue-88756-default-output
# doesn't work due to the way the rustc test suite is invoked. # doesn't work due to the way the rustc test suite is invoked.
# should work when using ./x.py test the way it is intended # should work when using ./x.py test the way it is intended
# ============================================================ # ============================================================