diff options
| author | Tshepang Mbambo <hopsi@tuta.io> | 2025-06-19 22:14:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-19 22:14:30 +0200 |
| commit | 6ad42bf4e7ab81ec3d66a5e47dfe01dc51603c0b (patch) | |
| tree | 59d2cbb81c6cf1bb95feb51963d037fd67fc51bf /compiler/rustc_errors/src/json.rs | |
| parent | f25cfe83f2a13d96731861caae7236372f6445d5 (diff) | |
| parent | d854d563445082268ca8e7dd76b6ccde0342c2b3 (diff) | |
| download | rust-6ad42bf4e7ab81ec3d66a5e47dfe01dc51603c0b.tar.gz rust-6ad42bf4e7ab81ec3d66a5e47dfe01dc51603c0b.zip | |
Merge pull request #2477 from rust-lang/rustc-pull
Rustc pull update
Diffstat (limited to 'compiler/rustc_errors/src/json.rs')
| -rw-r--r-- | compiler/rustc_errors/src/json.rs | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index a6583407b7e..d67e2ba2d60 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -28,9 +28,10 @@ use termcolor::{ColorSpec, WriteColor}; use crate::diagnostic::IsLint; use crate::emitter::{ ColorConfig, Destination, Emitter, HumanEmitter, HumanReadableErrorType, OutputTheme, - should_show_source_code, + TimingEvent, should_show_source_code, }; use crate::registry::Registry; +use crate::timings::{TimingRecord, TimingSection}; use crate::translation::{Translate, to_fluent_args}; use crate::{ CodeSuggestion, FluentBundle, LazyFallbackBundle, MultiSpan, SpanLabel, Subdiag, Suggestions, @@ -104,6 +105,7 @@ impl JsonEmitter { enum EmitTyped<'a> { Diagnostic(Diagnostic), Artifact(ArtifactNotification<'a>), + SectionTiming(SectionTimestamp<'a>), FutureIncompat(FutureIncompatReport<'a>), UnusedExtern(UnusedExterns<'a>), } @@ -135,6 +137,21 @@ impl Emitter for JsonEmitter { } } + fn emit_timing_section(&mut self, record: TimingRecord, event: TimingEvent) { + let event = match event { + TimingEvent::Start => "start", + TimingEvent::End => "end", + }; + let name = match record.section { + TimingSection::Linking => "link", + }; + let data = SectionTimestamp { name, event, timestamp: record.timestamp }; + let result = self.emit(EmitTyped::SectionTiming(data)); + if let Err(e) = result { + panic!("failed to print timing section: {e:?}"); + } + } + fn emit_future_breakage_report(&mut self, diags: Vec<crate::DiagInner>, registry: &Registry) { let data: Vec<FutureBreakageItem<'_>> = diags .into_iter() @@ -264,6 +281,16 @@ struct ArtifactNotification<'a> { } #[derive(Serialize)] +struct SectionTimestamp<'a> { + /// Name of the section + name: &'a str, + /// Start/end of the section + event: &'a str, + /// Opaque timestamp. + timestamp: u128, +} + +#[derive(Serialize)] struct FutureBreakageItem<'a> { // Always EmitTyped::Diagnostic, but we want to make sure it gets serialized // with "$message_type". |
