pub struct Handler {
inner: RefCell<HandlerInner>,
}
Expand description
A handler deals with errors and other compiler output.
Fields§
§inner: RefCell<HandlerInner>
The inner handler.
RefCell
is used here to avoid &mut
all over the compiler.
Implementations§
Source§impl Handler
impl Handler
Sourcepub fn new_with_buf() -> (Self, BufferEmitter)
pub fn new_with_buf() -> (Self, BufferEmitter)
Construct a Handler
that will append to buf
.
Sourcepub fn with<T>(
logic: impl for<'a> FnOnce(&'a Handler) -> Result<T, LeoError>,
) -> Result<T, ErrBuffer>
pub fn with<T>( logic: impl for<'a> FnOnce(&'a Handler) -> Result<T, LeoError>, ) -> Result<T, ErrBuffer>
Runs logic
provided a handler that collects all errors into the String
,
or if there were none, returns some T
.
Sourcepub fn emit_warning(&self, warning: LeoWarning)
pub fn emit_warning(&self, warning: LeoWarning)
Emit the error err
.
Sourcepub fn fatal_err(&self, err: LeoError) -> !
pub fn fatal_err(&self, err: LeoError) -> !
Emits the error err
.
This will immediately abort compilation.
Sourcepub fn warning_count(&self) -> usize
pub fn warning_count(&self) -> usize
The number of warnings thus far.
Sourcepub fn had_errors(&self) -> bool
pub fn had_errors(&self) -> bool
Did we have any errors thus far?
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Handler
impl !RefUnwindSafe for Handler
impl !Send for Handler
impl !Sync for Handler
impl Unpin for Handler
impl !UnwindSafe for Handler
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