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

Cleanup things in and around Diagnostic #119763

Merged
merged 6 commits into from
Jan 11, 2024

Commits on Jan 10, 2024

  1. Rename TRACK_DIAGNOSTICS as TRACK_DIAGNOSTIC.

    Because the values put into it are functions named `track_diagnostic`
    and `default_track_diagnostic`.
    nnethercote committed Jan 10, 2024
    Configuration menu
    Copy the full SHA
    06cf881 View commit details
    Browse the repository at this point in the history
  2. Change how force-warn lint diagnostics are recorded.

    `is_force_warn` is only possible for diagnostics with `Level::Warning`,
    but it is currently stored in `Diagnostic::code`, which every diagnostic
    has.
    
    This commit:
    - removes the boolean `DiagnosticId::Lint::is_force_warn` field;
    - adds a `ForceWarning` variant to `Level`.
    
    Benefits:
    - The common `Level::Warning` case now has no arguments, replacing
      lots of `Warning(None)` occurrences.
    - `rustc_session::lint::Level` and `rustc_errors::Level` are more
      similar, both having `ForceWarning` and `Warning`.
    nnethercote committed Jan 10, 2024
    Configuration menu
    Copy the full SHA
    0e388f2 View commit details
    Browse the repository at this point in the history
  3. Reset lint_err_count in DiagCtxt::reset_err_count.

    It's missing but should obviously be included.
    nnethercote committed Jan 10, 2024
    Configuration menu
    Copy the full SHA
    12ba450 View commit details
    Browse the repository at this point in the history
  4. Move DiagCtxtInner::deduplicated_warn_count.

    To put it next to a similar field.
    nnethercote committed Jan 10, 2024
    Configuration menu
    Copy the full SHA
    8866780 View commit details
    Browse the repository at this point in the history
  5. Replace warn_count.

    There are four functions that adjust error and warning counts:
    - `stash_diagnostic` (increment)
    - `steal_diagnostic` (decrement)
    - `emit_stashed_diagnostics) (decrement)
    - `emit_diagnostic` (increment)
    
    The first three all behave similarly, and only update `warn_count` for
    forced warnings. But the last one updates `warn_count` for both forced
    and non-forced warnings.
    
    Seems like a bug. How should it be fixed? Well, `warn_count` is only
    used in one place: `DiagCtxtInner::drop`, where it's part of the
    condition relating to the printing of `good_path_delayed_bugs`. The
    intention of that condition seems to be "have any errors been printed?"
    so this commit replaces `warn_count` with `has_printed`, which is set
    when printing occurs. This is simpler than all the ahead-of-time
    incrementing and decrementing.
    nnethercote committed Jan 10, 2024
    Configuration menu
    Copy the full SHA
    56c3265 View commit details
    Browse the repository at this point in the history
  6. Simplify lint error counting.

    Of the error levels satisfying `is_error`, `Level::Error` is the only
    one that can be a lint, so there's no need to check for it.
    
    (And even if it wasn't, it would make more sense to include
    non-`Error`-but-`is_error` lints under `lint_err_count` than under
    `err_count`.)
    nnethercote committed Jan 10, 2024
    Configuration menu
    Copy the full SHA
    dd61eba View commit details
    Browse the repository at this point in the history