Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit e6794dd

Browse files
committed
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.
1 parent e55df62 commit e6794dd

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

src/librustdoc/lib.rs

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,16 @@ pub fn main() {
177177
init_logging(&early_dcx);
178178
rustc_driver::init_logger(&early_dcx, rustc_log::LoggerConfig::from_env("RUSTDOC_LOG"));
179179

180-
let exit_code = rustc_driver::catch_with_exit_code(|| match get_args(&early_dcx) {
181-
Some(args) => main_args(&mut early_dcx, &args, using_internal_features),
182-
_ =>
183-
{
184-
#[allow(deprecated)]
185-
Err(ErrorGuaranteed::unchecked_claim_error_was_emitted())
186-
}
180+
let exit_code = rustc_driver::catch_with_exit_code(|| {
181+
let args = env::args_os()
182+
.enumerate()
183+
.map(|(i, arg)| {
184+
arg.into_string().unwrap_or_else(|arg| {
185+
early_dcx.early_fatal(format!("argument {i} is not valid Unicode: {arg:?}"))
186+
})
187+
})
188+
.collect::<Vec<_>>();
189+
main_args(&mut early_dcx, &args, using_internal_features)
187190
});
188191
process::exit(exit_code);
189192
}
@@ -219,19 +222,6 @@ fn init_logging(early_dcx: &EarlyDiagCtxt) {
219222
tracing::subscriber::set_global_default(subscriber).unwrap();
220223
}
221224

222-
fn get_args(early_dcx: &EarlyDiagCtxt) -> Option<Vec<String>> {
223-
env::args_os()
224-
.enumerate()
225-
.map(|(i, arg)| {
226-
arg.into_string()
227-
.map_err(|arg| {
228-
early_dcx.early_warn(format!("Argument {i} is not valid Unicode: {arg:?}"));
229-
})
230-
.ok()
231-
})
232-
.collect()
233-
}
234-
235225
fn opts() -> Vec<RustcOptGroup> {
236226
let stable: fn(_, fn(&mut getopts::Options) -> &mut _) -> _ = RustcOptGroup::stable;
237227
let unstable: fn(_, fn(&mut getopts::Options) -> &mut _) -> _ = RustcOptGroup::unstable;

0 commit comments

Comments
 (0)