-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 some more #118587
Cleanup error handlers some more #118587
Commits on Dec 4, 2023
-
Give
Handler::fatal
andSession::fatal
the same return type.Currently, `Handler::fatal` returns `FatalError`. But `Session::fatal` returns `!`, because it calls `Handler::fatal` and then calls `raise` on the result. This inconsistency is unfortunate. This commit changes `Handler::fatal` to do the `raise` itself, changing its return type to `!`. This is safe because there are only two calls to `Handler::fatal`, one in `rustc_session` and one in `rustc_codegen_cranelift`, and they both call `raise` on the result. `HandlerInner::fatal` still returns `FatalError`, so I renamed it `fatal_no_raise` to emphasise the return type difference.
Configuration menu - View commit details
-
Copy full SHA for 114380d - Browse repository at this point
Copy the full SHA 114380dView commit details -
Inline and remove
DiagnosticBuilder::new_diagnostic_*
functions.They each have a single call site.
Configuration menu - View commit details
-
Copy full SHA for d4933aa - Browse repository at this point
Copy the full SHA d4933aaView commit details -
Inline and remove more
DiagnosticBuilder::new_diagnostic_*
functions.They each have a single call site. Note: the `make_diagnostic_builder` calls in `lib.rs` will be replaced in a subsequent commit.
Configuration menu - View commit details
-
Copy full SHA for ab640ca - Browse repository at this point
Copy the full SHA ab640caView commit details -
`sess` is a terribly misleading name for a `Handler`! This confused me for a bit.
Configuration menu - View commit details
-
Copy full SHA for 6a95dee - Browse repository at this point
Copy the full SHA 6a95deeView commit details -
Always use
G
forEmissionGuarantee
type variables.That's what is mostly used. This commit changes a few `EM` and `E` and `T` type variables to `G`.
Configuration menu - View commit details
-
Copy full SHA for ed95f39 - Browse repository at this point
Copy the full SHA ed95f39View commit details -
Avoid
Diagnostic::new_with_code(..., None, ...)
.`Diagnostic::new` can be used instead.
Configuration menu - View commit details
-
Copy full SHA for 32dc78e - Browse repository at this point
Copy the full SHA 32dc78eView commit details -
Configuration menu - View commit details
-
Copy full SHA for d51b3db - Browse repository at this point
Copy the full SHA d51b3dbView commit details -
De-genericize some
IntoDiagnostic
impls.These impls are all needed for just a single `IntoDiagnostic` type, not a family of them. Note that `ErrorGuaranteed` is the default type parameter for `IntoDiagnostic`.
Configuration menu - View commit details
-
Copy full SHA for b7e18ca - Browse repository at this point
Copy the full SHA b7e18caView commit details -
Use
DiagnosticBuilder::new
more.By making it generic, instead of only for `EmissionGuarantee = ()`, we can use it everywhere.
Configuration menu - View commit details
-
Copy full SHA for 8c20ad6 - Browse repository at this point
Copy the full SHA 8c20ad6View commit details -
Move some
HandlerInner
functions toHandler
.`Handler` is a wrapper around `HanderInner`. Some functions on on `Handler` just forward to the samed-named functions on `HandlerInner`. This commit removes as many of those as possible, implementing functions on `Handler` where possible, to avoid the boilerplate required for forwarding. The commit is moderately large but it's very mechanical.
Configuration menu - View commit details
-
Copy full SHA for a8ff867 - Browse repository at this point
Copy the full SHA a8ff867View commit details -
This is weird: `HandlerInner::emit` calls `HandlerInner::emit_diagnostic`, but only after doing a `treat-err-as-bug` check. Which is fine, *except* that there are multiple others paths for an `Error` or `Fatal` diagnostic to be passed to `HandlerInner::emit_diagnostic` without going through `HandlerInner::emit`, e.g. `Handler::span_err` call `Handler::emit_diag_at_span`, which calls `emit_diagnostic`. So that suggests that the coverage for `treat-err-as-bug` is incomplete. This commit removes `HandlerInner::emit` and moves the `treat-err-as-bug` check to `HandlerInner::emit_diagnostic`, so it cannot by bypassed.
Configuration menu - View commit details
-
Copy full SHA for 883bdb7 - Browse repository at this point
Copy the full SHA 883bdb7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3ab05ca - Browse repository at this point
Copy the full SHA 3ab05caView commit details -
Inline and remove
fatal_no_raise
.This makes `Handler::fatal` more like `Handler::{err,warn,bug,note}`.
Configuration menu - View commit details
-
Copy full SHA for 7811c97 - Browse repository at this point
Copy the full SHA 7811c97View commit details