pub struct InFlightDiagnostic<'h> { /* private fields */ }Expand description
Constructs an in-flight diagnostic using the builder pattern
Implementations§
Source§impl<'h> InFlightDiagnostic<'h>
impl<'h> InFlightDiagnostic<'h>
Sourcepub fn verbose(&self) -> bool
pub fn verbose(&self) -> bool
Returns whether this diagnostic should be generated with verbose detail. Intended to be used when building diagnostics in-flight by formatting functions which do not know what the current diagnostic configuration is
Sourcepub fn set_source_file(self, filename: impl Into<FileName>) -> Self
pub fn set_source_file(self, filename: impl Into<FileName>) -> Self
Sets the current source file to which this diagnostic applies
Sourcepub fn with_message(self, message: impl ToString) -> Self
pub fn with_message(self, message: impl ToString) -> Self
Sets the diagnostic message to message
Sourcepub fn with_primary_span(self, span: SourceSpan) -> Self
pub fn with_primary_span(self, span: SourceSpan) -> Self
Adds a primary label for span to this diagnostic, with no label message.
Sourcepub fn with_primary_label(
self,
span: SourceSpan,
message: impl ToString,
) -> Self
pub fn with_primary_label( self, span: SourceSpan, message: impl ToString, ) -> Self
Adds a primary label for span to this diagnostic, with the given message
A primary label is one which should be rendered as the relevant source code at which a diagnostic originates. Secondary labels are used for related items involved in the diagnostic.
Sourcepub fn with_secondary_label(
self,
span: SourceSpan,
message: impl ToString,
) -> Self
pub fn with_secondary_label( self, span: SourceSpan, message: impl ToString, ) -> Self
Adds a secondary label for span to this diagnostic, with the given message
A secondary label is used to point out related items in the source code which are relevant to the diagnostic, but which are not themselves the point at which the diagnostic originates.
Sourcepub fn with_primary_label_line_and_col(
self,
line: u32,
column: u32,
message: Option<String>,
) -> Self
pub fn with_primary_label_line_and_col( self, line: u32, column: u32, message: Option<String>, ) -> Self
Like with_primary_label, but rather than a SourceSpan, it accepts a
line and column number, which will be mapped to an appropriate span by
the CodeMap.
Sourcepub fn with_label(
self,
style: LabelStyle,
filename: Option<FileName>,
line: u32,
column: u32,
message: Option<String>,
) -> Self
pub fn with_label( self, style: LabelStyle, filename: Option<FileName>, line: u32, column: u32, message: Option<String>, ) -> Self
This is a lower-level function for adding labels to diagnostics, providing full control over its style, content, and location in the source code.
Sourcepub fn with_note(self, note: impl ToString) -> Self
pub fn with_note(self, note: impl ToString) -> Self
Adds a note to the diagnostic
Notes are used for explaining general concepts or suggestions related to a diagnostic, and are not associated with any particular source location. They are always rendered after the other diagnostic content.
Sourcepub fn add_note(&mut self, note: impl ToString)
pub fn add_note(&mut self, note: impl ToString)
Like with_note, but is intended for use cases where the
fluent/builder pattern used here is cumbersome.
Sourcepub fn take(self) -> Diagnostic
pub fn take(self) -> Diagnostic
Consume this InFlightDiagnostic and extract the underlying Diagnostic
Sourcepub fn emit(self)
pub fn emit(self)
Emit the underlying Diagnostic via the [DiagnosticHandler]