Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some unchecked_claim_error_was_emitted calls #120735

Merged
merged 6 commits into from
Feb 7, 2024

Commits on Feb 6, 2024

  1. Remove return value from emit_stashed_diagnostics.

    It's never used.
    nnethercote committed Feb 6, 2024
    Configuration menu
    Copy the full SHA
    8d1c20a View commit details
    Browse the repository at this point in the history

Commits on Feb 7, 2024

  1. Remove an unchecked_claim_error_was_emitted call.

    When `catch_fatal_errors` catches a `FatalErrorMarker`, it returns an
    `ErrorGuaranteed` that is conjured out of thin air with
    `unchecked_claim_error_was_emitted`. But that `ErrorGuaranteed` is never
    used.
    
    This commit changes it to instead conjure a `FatalError` out of thin
    air. (A non-deprecated action!) This makes more sense because
    `FatalError` and `FatalErrorMarker` are a natural pairing -- a
    `FatalErrorMarker` is created by calling `FatalError::raise`, so this is
    effectively getting back the original `FatalError`.
    
    This requires a tiny change in `catch_with_exit_code`. The old result of
    the `catch_fatal_errors` call there was
    `Result<Result<(), ErrorGuaranteed>, ErrorGuaranteed>` which could be
    `flatten`ed into `Result<(), ErrorGuaranteed>`. The new result of the
    `catch_fatal_errors` calls is
    `Result<Result<(), ErrorGuaranteed>, FatalError>`, which can't be
    `flatten`ed but is still easily matched for the success case.
    nnethercote committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    e55df62 View commit details
    Browse the repository at this point in the history
  2. 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.
    nnethercote committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    e6794dd View commit details
    Browse the repository at this point in the history
  3. 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`.
    nnethercote committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    83adf88 View commit details
    Browse the repository at this point in the history
  4. Tighten up ErrorGuaranteed handling.

    - In `emit_producing_error_guaranteed`, only allow `Level::Error`.
    - In `emit_diagnostic`, only produce `ErrorGuaranteed` for `Level` and
      `DelayedBug`. (Not `Bug` or `Fatal`. They don't need it, because the
      relevant `emit` methods abort.)
    - Add/update various comments.
    nnethercote committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    97c157f View commit details
    Browse the repository at this point in the history
  5. Rename unchecked_claim_error_was_emitted as `unchecked_error_guaran…

    …teed`.
    
    It's more to-the-point.
    nnethercote committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    6889fe3 View commit details
    Browse the repository at this point in the history