diff options
| author | Scott Schafer <schaferjscott@gmail.com> | 2025-06-02 23:40:01 -0600 |
|---|---|---|
| committer | Scott Schafer <schaferjscott@gmail.com> | 2025-07-03 07:19:25 -0600 |
| commit | 6bef238b6346911d29a1ee0b067dc003da15f828 (patch) | |
| tree | ac560f56261d7b5bfd3c0bdb285b9609b2fbb9d4 /compiler/rustc_errors/src/json.rs | |
| parent | d6120810e56387730b2e86115471354c8084ca4a (diff) | |
| download | rust-6bef238b6346911d29a1ee0b067dc003da15f828.tar.gz rust-6bef238b6346911d29a1ee0b067dc003da15f828.zip | |
refactor: Make -Ztrack-diagnostics emit like a note
Diffstat (limited to 'compiler/rustc_errors/src/json.rs')
| -rw-r--r-- | compiler/rustc_errors/src/json.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index 4348610be0a..719d4ca625a 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -372,13 +372,16 @@ impl Diagnostic { }; let level = diag.level.to_str(); let spans = DiagnosticSpan::from_multispan(&diag.span, &args, je); - let children = diag + let mut children: Vec<Diagnostic> = diag .children .iter() .map(|c| Diagnostic::from_sub_diagnostic(c, &args, je)) .chain(sugg) .collect(); - + if je.track_diagnostics && diag.span.has_primary_spans() && !diag.span.is_dummy() { + children + .insert(0, Diagnostic::from_sub_diagnostic(&diag.emitted_at_sub_diag(), &args, je)); + } let buf = BufWriter::default(); let mut dst: Destination = Box::new(buf.clone()); let short = je.json_rendered.short(); |
