pub struct DiagnosticBuilder {
severity: ErrorSeverity,
location: SourceLocation,
message: String,
code: ErrorCode,
suggestions: Vec<FixSuggestion>,
related: Vec<RelatedInfo>,
source_snippet: Option<String>,
}Expand description
Builder for creating rich diagnostic messages
Fields§
§severity: ErrorSeverity§location: SourceLocation§message: String§code: ErrorCode§suggestions: Vec<FixSuggestion>§source_snippet: Option<String>Implementations§
Source§impl DiagnosticBuilder
impl DiagnosticBuilder
Sourcepub fn error(code: ErrorCode, message: impl Into<String>) -> Self
pub fn error(code: ErrorCode, message: impl Into<String>) -> Self
Create a new error diagnostic
Sourcepub fn warning(code: ErrorCode, message: impl Into<String>) -> Self
pub fn warning(code: ErrorCode, message: impl Into<String>) -> Self
Create a new warning diagnostic
Sourcepub fn at(self, location: SourceLocation) -> Self
pub fn at(self, location: SourceLocation) -> Self
Set the source location
Sourcepub fn suggest(self, suggestion: FixSuggestion) -> Self
pub fn suggest(self, suggestion: FixSuggestion) -> Self
Add a fix suggestion
Add related information
Sourcepub fn with_snippet(self, snippet: impl Into<String>) -> Self
pub fn with_snippet(self, snippet: impl Into<String>) -> Self
Add source code snippet
Sourcepub fn build(self) -> CompilerError
pub fn build(self) -> CompilerError
Build the final CompilerError
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DiagnosticBuilder
impl RefUnwindSafe for DiagnosticBuilder
impl Send for DiagnosticBuilder
impl Sync for DiagnosticBuilder
impl Unpin for DiagnosticBuilder
impl UnwindSafe for DiagnosticBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more