-
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
Fix EmissionGuarantee
#119097
Fix EmissionGuarantee
#119097
Commits on Dec 18, 2023
-
This commit replaces this pattern: ``` err.into_diagnostic(dcx) ``` with this pattern: ``` dcx.create_err(err) ``` in a lot of places. It's a little shorter, makes the error level explicit, avoids some `IntoDiagnostic` imports, and is a necessary prerequisite for the next commit which will add a `level` arg to `into_diagnostic`. This requires adding `track_caller` on `create_err` to avoid mucking up the output of `tests/ui/track-diagnostics/track4.rs`. It probably should have been there already.
Configuration menu - View commit details
-
Copy full SHA for cea683c - Browse repository at this point
Copy the full SHA cea683cView commit details -
Remove unnecessary
use
items in derivedIntoDiagnostic
impls.Presumably these are a hangover from an earlier time when they were necessary.
Configuration menu - View commit details
-
Copy full SHA for 18251c4 - Browse repository at this point
Copy the full SHA 18251c4View commit details -
Streamline
Diagnostic
proc macro.First, it is parameterized by the name of the diagnostic and the DiagCtxt. These are given to `session_diagnostic_derive` and `lint_diagnostic_derive`. But the names are hard-wired as "diag" and "handler" (should be "dcx"), and there's no clear reason for the parameterization. So this commit removes the parameterization and hard-wires the names internally. Once that is done `DiagnosticDeriveBuilder` is reduced to a trivial wrapper around `DiagnosticDeriveKind`, and can be removed. Also, `DiagnosticDerive` and `LintDiagnosticDerive` don't need the `builder` field, because it has been reduced to a kind, and they know their own kind. This avoids the need for some `let`/`else`/`unreachable!` kind checks And `DiagnosticDeriveVariantBuilder` no longer needs a lifetime, because the `parent` field is changed to `kind`, which is now a trivial copy type.
Configuration menu - View commit details
-
Copy full SHA for 31df50c - Browse repository at this point
Copy the full SHA 31df50cView commit details -
Add
level
arg tointo_diagnostic
.And make all hand-written `IntoDiagnostic` impls generic, by using `DiagnosticBuilder::new(dcx, level, ...)` instead of e.g. `dcx.struct_err(...)`. This means the `create_*` functions are the source of the error level. This change will let us remove `struct_diagnostic`. Note: `#[rustc_lint_diagnostics]` is added to `DiagnosticBuilder::new`, it's necessary to pass diagnostics tests now that it's used in `into_diagnostic` functions.
Configuration menu - View commit details
-
Copy full SHA for e7724a2 - Browse repository at this point
Copy the full SHA e7724a2View commit details -
Remove
struct_diagnostic
andG::make_diagnostic_builder
.`EmissionGuarantee` no longer determines the error level, the `create_*` functions do.
Configuration menu - View commit details
-
Copy full SHA for 3a5f28f - Browse repository at this point
Copy the full SHA 3a5f28fView commit details -
Add
EmitResult
associated type toEmissionGuarantee
.This lets different error levels share the same return type from `emit_*`. - A lot of inconsistencies in the `DiagCtxt` API are removed. - `Noted` is removed. - `FatalAbort` is introduced for fatal errors (abort via `raise`), replacing the `EmissionGuarantee` impl for `!`. - `Bug` is renamed `BugAbort` (to avoid clashing with `Level::Bug` and to mirror `FatalAbort`), and modified to work in the new way with bug errors (abort via panic). - Various diagnostic creators and emitters updated to the new, better signatures. Note that `DiagCtxt::bug` no longer needs to call `panic_any`, because `emit` handles that. Also shorten the obnoxiously long `diagnostic_builder_emit_producing_guarantee` name.
Configuration menu - View commit details
-
Copy full SHA for f545920 - Browse repository at this point
Copy the full SHA f545920View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9ed8733 - Browse repository at this point
Copy the full SHA 9ed8733View commit details -
Introduce
DiagCtxt::struct_bug
.This makes `DiagCtxt::bug` look like the other similar functions.
Configuration menu - View commit details
-
Copy full SHA for 072c157 - Browse repository at this point
Copy the full SHA 072c157View commit details
Commits on Dec 19, 2023
-
De-weirdify
fatally_break_rust
.The easter egg ICE on `break rust` is weird: it's the one ICE in the entire compiler that doesn't immediately abort, which makes it annoyingly inconsistent. This commit changes it to abort. As part of this, the extra notes are now appended onto the bug dignostic, rather than being printed as individual note diagnostics, which changes the output format a bit. These changes don't interferes with the joke, but they do help with my ongoing cleanups to error handling.
Configuration menu - View commit details
-
Copy full SHA for 2863298 - Browse repository at this point
Copy the full SHA 2863298View commit details -
Configuration menu - View commit details
-
Copy full SHA for 006446e - Browse repository at this point
Copy the full SHA 006446eView commit details