diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-02-06 20:47:47 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-02-07 18:57:46 +1100 |
| commit | e6794ddfb00e14b29b3befc5bc054a15094321b7 (patch) | |
| tree | 57e391c45a2441a340fc8f4eb1c89ae99c6bd23b /src/librustdoc/lib.rs | |
| parent | e55df623ead33023fe6c4488064e5d5e4e141b9e (diff) | |
| download | rust-e6794ddfb00e14b29b3befc5bc054a15094321b7.tar.gz rust-e6794ddfb00e14b29b3befc5bc054a15094321b7.zip | |
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.
Diffstat (limited to 'src/librustdoc/lib.rs')
| -rw-r--r-- | src/librustdoc/lib.rs | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 8c10f14116a..0fe3adadba3 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -177,13 +177,16 @@ pub fn main() { init_logging(&early_dcx); 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) { - Some(args) => main_args(&mut early_dcx, &args, using_internal_features), - _ => - { - #[allow(deprecated)] - Err(ErrorGuaranteed::unchecked_claim_error_was_emitted()) - } + let exit_code = rustc_driver::catch_with_exit_code(|| { + let args = env::args_os() + .enumerate() + .map(|(i, arg)| { + arg.into_string().unwrap_or_else(|arg| { + 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); } @@ -219,19 +222,6 @@ fn init_logging(early_dcx: &EarlyDiagCtxt) { 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> { let stable: fn(_, fn(&mut getopts::Options) -> &mut _) -> _ = RustcOptGroup::stable; let unstable: fn(_, fn(&mut getopts::Options) -> &mut _) -> _ = RustcOptGroup::unstable; |
