From 9632762b6be8eae04e0b4d12ec1cf24628b49506 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 11 Sep 2026 07:33:25 +1000 Subject: [PATCH 1/2] Remove `G` generic param from `Diag<'_, G>` It encodes the `emit` behaviour, one of: - `BugAbort`: Abort as a bug. - `FatalAbort`: Abort as a fatal error. - `ErrorGuaranteed`: Return an `ErrorGuaranteed` (the default). - `()`: return `()`. This is useful but `Diag` is very widely used and it's arguably not useful enough to be worth the generic parameter. This commit removes it. Benefits: - Many fewer generic parameters, including many functions where the genericity is entirely uninteresting. This includes every `Diagnostic::into_diag` and `Subdiagnostic::add_to_diag`. Removes the need for the comment about `` on `trait Diagnostic`. - No `PhantomData` in `Diag`. - Makes bootstrapping a bit faster. The downside is there is no longer a single `emit` method. - Getting a `!` return type requires calling `emit_bug` or `emit_fatal`. This only affects a few call sites. - Getting an `ErrorGuaranteed` return type requires calling `emit_err`. This affects a lot of call sites. (It arguably makes call sites more self-documenting.) - Using the wrong `emit_*` on a diagnostic causes a runtime abort, which previously couldn't occur. Seems unlikely, but it's not impossible. - Note: If no particular return type is needed, `emit` can be used for any diagnostic. (Bug/fatal diagnostics will still trigger abort.) --- src/diagnostics/diagnostic-structs.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diagnostics/diagnostic-structs.md b/src/diagnostics/diagnostic-structs.md index 7ca97b7b05..f8df01ba5e 100644 --- a/src/diagnostics/diagnostic-structs.md +++ b/src/diagnostics/diagnostic-structs.md @@ -93,8 +93,8 @@ In the end, the `Diagnostic` derive will generate an implementation of `Diagnostic` that looks like the following: ```rust,ignore -impl<'a, G> Diagnostic<'a> for FieldAlreadyDeclared { - fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> { +impl<'a> Diagnostic<'a> for FieldAlreadyDeclared { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let mut diag = Diag::new(dcx, level, "field `{$field_name}` is already declared"); diag.set_span(self.span); diag.span_label( From d9c457a63f327c352b5aea85bb549ffcd1f11172 Mon Sep 17 00:00:00 2001 From: The rustc-josh-sync Cronjob Bot Date: Mon, 21 Sep 2026 17:26:15 +0000 Subject: [PATCH 2/2] Prepare for merging from rust-lang/rust This updates the rust-version file to 56fad885ebfb0447660870715da4dfa75deae93d. --- rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-version b/rust-version index 1c3d6e0224..6b9ce9470f 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -420ed2a0c3d7225b1744266fd884d431b4d8cfe0 +56fad885ebfb0447660870715da4dfa75deae93d