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 error handlers: round 4 #119171

Merged
merged 22 commits into from
Dec 23, 2023
Merged

Commits on Dec 23, 2023

  1. Add comments to Level.

    There is room for improvement on some of these, but something is better
    than nothing.
    nnethercote committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    c8c1615 View commit details
    Browse the repository at this point in the history
  2. Streamline struct_lint_level.

    We can just get the error level in the `match` and then use
    `DiagnosticBuilder::new`. This then means a number of `DiagCtxt`
    functions are no longer needed, because this was the one place that used
    them.
    
    Note: the commit changes the treatment of spans for `Expect`, which was
    different to all the other cases, but this has no apparent effect.
    nnethercote committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    de303b8 View commit details
    Browse the repository at this point in the history
  3. Improve use items in compiler/rustc_errors/src/lib.rs.

    There are a bunch of them about 400 lines down, which is weird and
    annoying. This commit moves them up and puts them in a more sensible
    order.
    nnethercote committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    1b36958 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    aec78dd View commit details
    Browse the repository at this point in the history
  5. Use IntoDiagnostic default.

    `IntoDiagnostic` defaults to `G = ErrorGuaranteed`. Take advantage of
    this in one place that currently doesn't.
    nnethercote committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    6257f3b View commit details
    Browse the repository at this point in the history
  6. Give DiagnosticBuilder a default type.

    `IntoDiagnostic` defaults to `ErrorGuaranteed`, because errors are the
    most common diagnostic level. It makes sense to do likewise for the
    closely-related (and much more widely used) `DiagnosticBuilder` type,
    letting us write `DiagnosticBuilder<'a, ErrorGuaranteed>` as just
    `DiagnosticBuilder<'a>`. This cuts over 200 lines of code due to many
    multi-line things becoming single line things.
    nnethercote committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    757d6f6 View commit details
    Browse the repository at this point in the history
  7. Tweak flush_delayed.

    - Take a `Vec` instead of an iterator, because that's all that is
      needed.
    - Do an early return for the "no bugs" case.
    - Use `enumerate` and an `i == 0` test to identify the first bug.
    
    Those changes mean the `no_bug` variable can be removed, which I found
    hard to read.
    nnethercote committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    a108a3b View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    6f147af View commit details
    Browse the repository at this point in the history
  9. Introduce DiagCtxt::treat_next_err_as_bug.

    To fix a FIXME.
    nnethercote committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    1502596 View commit details
    Browse the repository at this point in the history
  10. Remove DiagCtxtInner::span_bug.

    `DiagCtxt::span_bug` is different to the other `DiagCtxt::span_*`
    methods. This commit makes it the same, which requires changing
    `DiagCtxt::span_delayed_bug` to not do everything within the
    `inner.borrow_mut()`.
    nnethercote committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    1f08bfa View commit details
    Browse the repository at this point in the history
  11. Rename EarlyDiagCtxt methods to match DiagCtxt.

    - `early_error_no_abort` -> `early_err`
    - `early_error` -> `early_fatal`
    - `early_struct_error` -> `early_struct_fatal`
    nnethercote committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    3a1b8e6 View commit details
    Browse the repository at this point in the history
  12. Remove Diagnostic::new_with_code.

    Its single use can be replaced with `Diagnostic::new_with_messages`.
    nnethercote committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    d7a3b62 View commit details
    Browse the repository at this point in the history
  13. Improve some names.

    Lots of vectors of messages called `message` or `msg`. This commit
    pluralizes them.
    
    Note that `emit_message_default` and `emit_messages_default` both
    already existed, and both process a vector, so I renamed the former
    `emit_messages_default_inner` because it's called by the latter.
    nnethercote committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    824667f View commit details
    Browse the repository at this point in the history
  14. Remove render_span args from Diagnostic::{sub,sub_with_highlight}.

    They're always `None`.
    nnethercote committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    125337b View commit details
    Browse the repository at this point in the history
  15. Remove SubDiagnostic::render_span.

    It's only ever set to `None`.
    nnethercote committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    ce0f703 View commit details
    Browse the repository at this point in the history
  16. Remove LabelKind.

    It has three variants, but only `LabelKind::Label` is ever used. This
    means `SingleLabelManySpans::kind` can also be removed.
    nnethercote committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    49040d0 View commit details
    Browse the repository at this point in the history
  17. Take full advantage of a use Level::*;.

    Some of the `Level::` qualifiers in this file are omitted. This commit
    removes the remainder.
    nnethercote committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    e0461f9 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    3944301 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    81f50fd View commit details
    Browse the repository at this point in the history
  20. Fix a comment.

    There are quite a few hand-written `IntoDiagnostic` impls.
    nnethercote committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    3db58e6 View commit details
    Browse the repository at this point in the history
  21. Remove all uses of DiagnosticBuilder::forget_guarantee().

    There are only three. It's simpler to make the type
    `DiagnosticBuilder<'_, ()>` from the start, no matter the level, than to
    change the guarantee later.
    nnethercote committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    00e8485 View commit details
    Browse the repository at this point in the history
  22. Remove DiagnosticBuilder::forget_guarantee.

    It's unused. And this means `DiagnosticBuilderInner` no longer needs to
    be separate from `DiagnosticBuilder`.
    nnethercote committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    2cd14bc View commit details
    Browse the repository at this point in the history