rustdoc: make main
more like rustc's.
By making non-unicode arguments a fatal error instead of a warning, we don't need to handle what comes after, which avoids the need for an `unchecked_claim_error_was_emitted` call.
This commit is contained in:
parent
e55df623ea
commit
e6794ddfb0
1 changed files with 10 additions and 20 deletions
|
@ -177,13 +177,16 @@ pub fn main() {
|
||||||
init_logging(&early_dcx);
|
init_logging(&early_dcx);
|
||||||
rustc_driver::init_logger(&early_dcx, rustc_log::LoggerConfig::from_env("RUSTDOC_LOG"));
|
rustc_driver::init_logger(&early_dcx, rustc_log::LoggerConfig::from_env("RUSTDOC_LOG"));
|
||||||
|
|
||||||
let exit_code = rustc_driver::catch_with_exit_code(|| match get_args(&early_dcx) {
|
let exit_code = rustc_driver::catch_with_exit_code(|| {
|
||||||
Some(args) => main_args(&mut early_dcx, &args, using_internal_features),
|
let args = env::args_os()
|
||||||
_ =>
|
.enumerate()
|
||||||
{
|
.map(|(i, arg)| {
|
||||||
#[allow(deprecated)]
|
arg.into_string().unwrap_or_else(|arg| {
|
||||||
Err(ErrorGuaranteed::unchecked_claim_error_was_emitted())
|
early_dcx.early_fatal(format!("argument {i} is not valid Unicode: {arg:?}"))
|
||||||
}
|
})
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
main_args(&mut early_dcx, &args, using_internal_features)
|
||||||
});
|
});
|
||||||
process::exit(exit_code);
|
process::exit(exit_code);
|
||||||
}
|
}
|
||||||
|
@ -219,19 +222,6 @@ fn init_logging(early_dcx: &EarlyDiagCtxt) {
|
||||||
tracing::subscriber::set_global_default(subscriber).unwrap();
|
tracing::subscriber::set_global_default(subscriber).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_args(early_dcx: &EarlyDiagCtxt) -> Option<Vec<String>> {
|
|
||||||
env::args_os()
|
|
||||||
.enumerate()
|
|
||||||
.map(|(i, arg)| {
|
|
||||||
arg.into_string()
|
|
||||||
.map_err(|arg| {
|
|
||||||
early_dcx.early_warn(format!("Argument {i} is not valid Unicode: {arg:?}"));
|
|
||||||
})
|
|
||||||
.ok()
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn opts() -> Vec<RustcOptGroup> {
|
fn opts() -> Vec<RustcOptGroup> {
|
||||||
let stable: fn(_, fn(&mut getopts::Options) -> &mut _) -> _ = RustcOptGroup::stable;
|
let stable: fn(_, fn(&mut getopts::Options) -> &mut _) -> _ = RustcOptGroup::stable;
|
||||||
let unstable: fn(_, fn(&mut getopts::Options) -> &mut _) -> _ = RustcOptGroup::unstable;
|
let unstable: fn(_, fn(&mut getopts::Options) -> &mut _) -> _ = RustcOptGroup::unstable;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue