pub struct TypeError(/* private fields */);
Expand description
Error indicating that a type is invalid.
Note that the “type” of a thing (eg the type of a FunctionParam
)
in crate::namespace::types
is sometimes represented as a
Result<Type, TypeError>
.
If, for example, a function parameter has an undefined type, we emit a Diagnostic
message,
give that parameter a “type” of Err(TypeError)
, and carry on. If/when that parameter is
used in the function body, we assume that a diagnostic message about the undefined type
has already been emitted, and halt the analysis of the function body.
To ensure that that assumption is sound, a diagnostic must be emitted before creating
a TypeError
. So that the rust compiler can help us enforce this rule, a TypeError
cannot be constructed without providing a DiagnosticVoucher
. A voucher can be obtained
by calling an error function on an AnalyzerContext
.
Please don’t try to work around this restriction.
Example: TypeError::new(context.error("something is wrong", some_span, "this thing"))
Implementations§
Trait Implementations§
Source§impl From<ConstEvalError> for TypeError
impl From<ConstEvalError> for TypeError
Source§fn from(err: ConstEvalError) -> Self
fn from(err: ConstEvalError) -> Self
Source§impl From<FatalError> for TypeError
impl From<FatalError> for TypeError
Source§fn from(err: FatalError) -> Self
fn from(err: FatalError) -> Self
Source§impl From<IncompleteItem> for TypeError
impl From<IncompleteItem> for TypeError
Source§fn from(err: IncompleteItem) -> Self
fn from(err: IncompleteItem) -> Self
Source§impl From<TypeError> for ConstEvalError
impl From<TypeError> for ConstEvalError
Source§impl From<TypeError> for FatalError
impl From<TypeError> for FatalError
impl Eq for TypeError
impl StructuralPartialEq for TypeError
Auto Trait Implementations§
impl Freeze for TypeError
impl RefUnwindSafe for TypeError
impl Send for TypeError
impl Sync for TypeError
impl Unpin for TypeError
impl UnwindSafe for TypeError
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.