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

Some cleanups around diagnostic levels. #120520

Merged
merged 4 commits into from
Feb 6, 2024

Commits on Feb 4, 2024

  1. Make Diagnostic::is_error return false for Level::FailureNote.

    It doesn't affect behaviour, but makes sense with (a) `FailureNote` having
    `()` as its emission guarantee, and (b) in `Level` the `is_error` levels
    now are all listed before the non-`is_error` levels.
    nnethercote committed Feb 4, 2024
    Configuration menu
    Copy the full SHA
    e8c3cbf View commit details
    Browse the repository at this point in the history
  2. Tighten the assertion in downgrade_to_delayed_bug.

    I.e. `Bug` and `Fatal` level diagnostics are never downgraded.
    nnethercote committed Feb 4, 2024
    Configuration menu
    Copy the full SHA
    5dd0431 View commit details
    Browse the repository at this point in the history
  3. Refactor emit_diagnostic.

    - Combine two different blocks involving
      `diagnostic.level.get_expectation_id()` into one.
    - Combine several `if`s involving `diagnostic.level` into a single
      `match`.
    
    This requires reordering some of the operations, but this has no
    functional effect.
    nnethercote committed Feb 4, 2024
    Configuration menu
    Copy the full SHA
    c367386 View commit details
    Browse the repository at this point in the history
  4. Split Level::DelayedBug in two.

    The two kinds of delayed bug have quite different semantics so a
    stronger conceptual separation is nice. (`is_error` is a good example,
    because the two kinds have different behaviour.)
    
    The commit also moves the `DelayedBug` variant after `Error` in `Level`,
    to reflect the fact that it's weaker than `Error` -- it might trigger an
    error but also might not. (The pre-existing `downgrade_to_delayed_bug`
    function also reflects the notion that delayed bugs are lower/after
    normal errors.)
    
    Plus it condenses some of the comments on `Level` into a table, for
    easier reading, and introduces `can_be_top_or_sub` to indicate which
    levels can be used in top-level diagnostics vs. subdiagnostics.
    
    Finally, it renames `DiagCtxtInner::span_delayed_bugs` as
    `DiagCtxtInner::delayed_bugs`. The `span_` prefix is unnecessary because
    some delayed bugs don't have a span.
    nnethercote committed Feb 4, 2024
    Configuration menu
    Copy the full SHA
    59e0bc2 View commit details
    Browse the repository at this point in the history