Skip to content

Commit 62ad57b

Browse files
committed
Make sure nested Diagnostics in FutureIncompat are also typed for consistency.
1 parent 5c81706 commit 62ad57b

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

compiler/rustc_errors/src/json.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl JsonEmitter {
161161
enum EmitTyped<'a> {
162162
Diagnostic(Diagnostic),
163163
Artifact(ArtifactNotification<'a>),
164-
FutureIncompat(FutureIncompatReport),
164+
FutureIncompat(FutureIncompatReport<'a>),
165165
UnusedExtern(UnusedExterns<'a, 'a, 'a>),
166166
}
167167

@@ -193,13 +193,17 @@ impl Emitter for JsonEmitter {
193193
}
194194

195195
fn emit_future_breakage_report(&mut self, diags: Vec<crate::Diagnostic>) {
196-
let data: Vec<FutureBreakageItem> = diags
196+
let data: Vec<FutureBreakageItem<'_>> = diags
197197
.into_iter()
198198
.map(|mut diag| {
199199
if diag.level == crate::Level::Allow {
200200
diag.level = crate::Level::Warning(None);
201201
}
202-
FutureBreakageItem { diagnostic: Diagnostic::from_errors_diagnostic(&diag, self) }
202+
FutureBreakageItem {
203+
diagnostic: EmitTyped::Diagnostic(Diagnostic::from_errors_diagnostic(
204+
&diag, self,
205+
)),
206+
}
203207
})
204208
.collect();
205209
let report = FutureIncompatReport { future_incompat_report: data };
@@ -311,13 +315,14 @@ struct ArtifactNotification<'a> {
311315
}
312316

313317
#[derive(Serialize)]
314-
struct FutureBreakageItem {
315-
diagnostic: Diagnostic,
318+
struct FutureBreakageItem<'a> {
319+
// Actually Diagnostic, but we want to make sure it gets serialized with `type`.
320+
diagnostic: EmitTyped<'a>,
316321
}
317322

318323
#[derive(Serialize)]
319-
struct FutureIncompatReport {
320-
future_incompat_report: Vec<FutureBreakageItem>,
324+
struct FutureIncompatReport<'a> {
325+
future_incompat_report: Vec<FutureBreakageItem<'a>>,
321326
}
322327

323328
// NOTE: Keep this in sync with the equivalent structs in rustdoc's

0 commit comments

Comments
 (0)