End unification of exit codes in librustdoc

This commit is contained in:
Guillaume Gomez
2020-05-09 13:37:26 +02:00
parent 7e855b5915
commit c8fb0d7ef3
3 changed files with 25 additions and 21 deletions

View File

@@ -450,20 +450,29 @@ fn main_args(args: &[String]) -> i32 {
rustc_interface::interface::default_thread_pool(options.edition, move || main_options(options))
}
fn wrap_return(diag: &rustc_errors::Handler, res: Result<(), String>) -> i32 {
match res {
Ok(()) => 0,
Err(err) => {
if !err.is_empty() {
diag.struct_err(&err).emit();
}
1
}
}
}
fn main_options(options: config::Options) -> i32 {
let diag = core::new_handler(options.error_format, None, &options.debugging_options);
match (options.should_test, options.markdown_input()) {
(true, true) => return markdown::test(options, &diag),
(true, false) => return test::run(options),
(true, true) => return wrap_return(&diag, markdown::test(options)),
(true, false) => return wrap_return(&diag, test::run(options)),
(false, true) => {
match markdown::render(&options.input, options.render_options, options.edition) {
Ok(()) => return 0,
Err(err) => {
diag.struct_err(&err).emit();
return 1;
}
}
return wrap_return(
&diag,
markdown::render(&options.input, options.render_options, options.edition),
);
}
(false, false) => {}
}