pub trait Emitter: Any {
// Required method
fn emit_diagnostic(&mut self, diagnostic: &mut Diag);
// Provided methods
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 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 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 Suggestions,
)
fn primary_span_formatted<'a>( &self, primary_span: &mut Cow<'a, MultiSpan>, suggestions: &mut Suggestions, )
Formats the substitutions of the primary_span
There are a lot of conditions to this method, but in short:
-
If the current
DiagInner
has only one visibleCodeSuggestion
, we format thehelp
suggestion depending on the content of the substitutions. In that case, we modify the span and clear the suggestions. -
If the current
DiagInner
has multiple suggestions, we leaveprimary_span
and the suggestions untouched.
Implementors§
impl Emitter for HumanBufferEmitter
impl Emitter for HumanEmitter
impl Emitter for InMemoryEmitter
impl Emitter for JsonEmitter
Available on crate feature
json
only.