diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-10-07 15:36:44 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-10-19 07:23:14 +1100 |
| commit | 2a62c92b25a8fbaf0fdd0fa8f8baabf7be9d9a91 (patch) | |
| tree | fbfbd9cd4600674387c70b794967490bab534200 | |
| parent | 021d1fbd007456e6a8f2a7b865545352afb66a3f (diff) | |
| download | rust-2a62c92b25a8fbaf0fdd0fa8f8baabf7be9d9a91.tar.gz rust-2a62c92b25a8fbaf0fdd0fa8f8baabf7be9d9a91.zip | |
Merge `main_options` into `main_args`.
There is no longer any need for them to be separate.
| -rw-r--r-- | src/librustdoc/lib.rs | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index ce6f7e817c6..7e0cc668d7b 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -674,35 +674,6 @@ fn usage(argv0: &str) { /// A result type used by several functions under `main()`. type MainResult = Result<(), ErrorGuaranteed>; -fn main_args(at_args: &[String]) -> MainResult { - let args = rustc_driver::args::arg_expand_all(at_args); - - let mut options = getopts::Options::new(); - for option in opts() { - (option.apply)(&mut options); - } - let matches = match options.parse(&args[1..]) { - Ok(m) => m, - Err(err) => { - early_error(ErrorOutputType::default(), &err.to_string()); - } - }; - - // Note that we discard any distinction between different non-zero exit - // codes from `from_matches` here. - let options = match config::Options::from_matches(&matches, args) { - Ok(opts) => opts, - Err(code) => { - return if code == 0 { - Ok(()) - } else { - Err(ErrorGuaranteed::unchecked_claim_error_was_emitted()) - }; - } - }; - main_options(options) -} - fn wrap_return(diag: &rustc_errors::Handler, res: Result<(), String>) -> MainResult { match res { Ok(()) => Ok(()), @@ -733,7 +704,33 @@ fn run_renderer<'tcx, T: formats::FormatRenderer<'tcx>>( } } -fn main_options(options: config::Options) -> MainResult { +fn main_args(at_args: &[String]) -> MainResult { + let args = rustc_driver::args::arg_expand_all(at_args); + + let mut options = getopts::Options::new(); + for option in opts() { + (option.apply)(&mut options); + } + let matches = match options.parse(&args[1..]) { + Ok(m) => m, + Err(err) => { + early_error(ErrorOutputType::default(), &err.to_string()); + } + }; + + // Note that we discard any distinction between different non-zero exit + // codes from `from_matches` here. + let options = match config::Options::from_matches(&matches, args) { + Ok(opts) => opts, + Err(code) => { + return if code == 0 { + Ok(()) + } else { + Err(ErrorGuaranteed::unchecked_claim_error_was_emitted()) + }; + } + }; + let diag = core::new_handler( options.error_format, None, |
