rustdoc: remove unchecked_claim_error_was_emitted
call in main_args
.
`main_args` calls `from_matches`, which does lots of initialization. If anything goes wrong, `from_matches` emits an error message and returns `Err(1)` (or `Err(3)`). `main_args` then turns the `Err(1)` into `Err(ErrorGuaranteed)`, because that's what `catch_with_exit_code` requires on error. But `catch_with_exit_code` doesn't do anything with the `ErrorGuaranteed`, it just exits with `EXIT_FAILURE`. We can avoid the creation of the `ErrorGuaranteed` (which requires an undesirable `unchecked_claim_error_was_emitted` call), by changing `from_matches` to instead eagerly abort if anything goes wrong. The behaviour from the user's point of view is the same: an early abort with an `EXIT_FAILURE` exit code. And we can also simplify `from_matches` to return an `Option` instead of a `Result`: - Old `Err(0)` case --> `None` - Old `Err(_)` case --> fatal error. This requires similar changes to `ScrapeExamplesOptions::new` and `load_call_locations`.
This commit is contained in:
parent
e6794ddfb0
commit
83adf883a2
3 changed files with 53 additions and 101 deletions
|
@ -720,15 +720,8 @@ fn main_args(
|
|||
// Note that we discard any distinction between different non-zero exit
|
||||
// codes from `from_matches` here.
|
||||
let (options, render_options) = match config::Options::from_matches(early_dcx, &matches, args) {
|
||||
Ok(opts) => opts,
|
||||
Err(code) => {
|
||||
return if code == 0 {
|
||||
Ok(())
|
||||
} else {
|
||||
#[allow(deprecated)]
|
||||
Err(ErrorGuaranteed::unchecked_claim_error_was_emitted())
|
||||
};
|
||||
}
|
||||
Some(opts) => opts,
|
||||
None => return Ok(()),
|
||||
};
|
||||
|
||||
let diag =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue