pub trait Emitter: Any {
// Required method
fn emit_diagnostic(&mut self, diagnostic: &mut Diag);
// Provided methods
fn emit_diagnostic_ref(&mut self, diagnostic: &Diag) { ... }
fn source_map(&self) -> Option<&Arc<SourceMap>> { ... }
fn supports_color(&self) -> bool { ... }
fn primary_span_formatted<'a>(
&self,
primary_span: &mut Cow<'a, MultiSpan>,
suggestions: &mut Cow<'a, Suggestions>,
) { ... }
}Expand description
Diagnostic emitter.
Required Methods§
Sourcefn emit_diagnostic(&mut self, diagnostic: &mut Diag)
fn emit_diagnostic(&mut self, diagnostic: &mut Diag)
Emits a diagnostic.
Provided Methods§
Sourcefn emit_diagnostic_ref(&mut self, diagnostic: &Diag)
fn emit_diagnostic_ref(&mut self, diagnostic: &Diag)
Emits a diagnostic by reference.
Sourcefn source_map(&self) -> Option<&Arc<SourceMap>>
fn source_map(&self) -> Option<&Arc<SourceMap>>
Returns a reference to the source map, if any.
Sourcefn supports_color(&self) -> bool
fn supports_color(&self) -> bool
Returns true if we can use colors in the current output stream.
Sourcefn primary_span_formatted<'a>(
&self,
primary_span: &mut Cow<'a, MultiSpan>,
suggestions: &mut Cow<'a, Suggestions>,
)
fn primary_span_formatted<'a>( &self, primary_span: &mut Cow<'a, MultiSpan>, suggestions: &mut Cow<'a, Suggestions>, )
Formats the substitutions of the primary_span
There are a lot of conditions to this method, but in short:
-
If the current
DiagInnerhas only one visibleCodeSuggestion, we format thehelpsuggestion depending on the content of the substitutions. In that case, we modify the span and clear the suggestions. -
If the current
DiagInnerhas multiple suggestions, we leaveprimary_spanand the suggestions untouched.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl Emitter for HumanBufferEmitter
impl Emitter for HumanEmitter
impl Emitter for InMemoryEmitter
impl Emitter for JsonEmitter
Available on crate feature
json only.