Skip to content

Commit 326b44e

Browse files
committed
Fix panic when compiling Rocket.
`Rustc::emit_diagnostic` reconstructs a diagnostic passed in from the macro machinery. Currently it uses the type `DiagnosticBuilder<'_, ErrorGuaranteed>`, which is incorrect, because the diagnostic might be a warning. And if it is a warning, because of the `ErrorGuaranteed` we end up calling into `emit_producing_error_guaranteed` and the assertion within that function (correctly) fails because the level is not an error level. The fix is simple: change the type to `DiagnosticBuilder<'_, ()>`. Using `()` works no matter what the diagnostic level is, and we don't need an `ErrorGuaranteed` here. The panic was reported in #120576.
1 parent f8131a4 commit 326b44e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compiler/rustc_expand/src/proc_macro_server.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ impl server::FreeFunctions for Rustc<'_, '_> {
510510

511511
fn emit_diagnostic(&mut self, diagnostic: Diagnostic<Self::Span>) {
512512
let message = rustc_errors::DiagnosticMessage::from(diagnostic.message);
513-
let mut diag: DiagnosticBuilder<'_, rustc_errors::ErrorGuaranteed> =
513+
let mut diag: DiagnosticBuilder<'_, ()> =
514514
DiagnosticBuilder::new(&self.sess().dcx, diagnostic.level.to_internal(), message);
515515
diag.span(MultiSpan::from_spans(diagnostic.spans));
516516
for child in diagnostic.children {

0 commit comments

Comments
 (0)