Emitter

Trait Emitter 

Source
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§

Source

fn emit_diagnostic(&mut self, diagnostic: &mut Diag)

Emits a diagnostic.

Provided Methods§

Source

fn source_map(&self) -> Option<&Arc<SourceMap>>

Returns a reference to the source map, if any.

Source

fn supports_color(&self) -> bool

Returns true if we can use colors in the current output stream.

Source

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 visible CodeSuggestion, we format the help 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 leave primary_span and the suggestions untouched.

Implementors§