Struct ErrorCollector

Source
pub struct ErrorCollector {
    errors: Vec<CompilerError>,
    seen_errors: HashSet<ErrorKey>,
}
Expand description

A centralized error collector that handles error creation, formatting, and deduplication

This provides a single source of truth for error handling in the semantic analysis system, ensuring consistent error formatting and efficient deduplication.

Fields§

§errors: Vec<CompilerError>§seen_errors: HashSet<ErrorKey>

Implementations§

Source§

impl ErrorCollector

Source

pub fn new() -> Self

Create a new error collector

Source

pub fn add_semantic_error( &mut self, error: SemanticAnalysisError, context: &CompilationContext, ) -> bool

Add a semantic analysis error to the collection

§Arguments
  • error - The semantic analysis error to add
  • context - The compilation context for error conversion
§Returns

true if the error was added (not a duplicate), false if it was deduplicated

Source

pub fn add_compiler_error(&mut self, error: CompilerError) -> bool

Add a compiler error directly to the collection

§Arguments
  • error - The compiler error to add
§Returns

true if the error was added (not a duplicate), false if it was deduplicated

Source

pub fn into_errors(self) -> Vec<CompilerError>

Get all collected errors

Source

pub fn has_errors(&self) -> bool

Check if any errors have been collected

Source

pub fn error_count(&self) -> usize

Get the number of unique errors collected

Trait Implementations§

Source§

impl Default for ErrorCollector

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.