Enum arithmetic_typing::error::ErrorKind

source ·
#[non_exhaustive]
pub enum ErrorKind<Prim: PrimitiveType> {
Show 20 variants TypeMismatch(Type<Prim>, Type<Prim>), TupleLenMismatch { lhs: TupleLen, rhs: TupleLen, context: TupleContext, }, UndefinedVar(String), RecursiveType(Type<Prim>), RepeatedAssignment(String), InvalidFieldName(String), CannotIndex, UnsupportedIndex, IndexOutOfBounds { index: usize, len: TupleLen, }, RepeatedField(String), CannotAccessFields, FieldsMismatch { lhs_fields: HashSet<String>, rhs_fields: HashSet<String>, }, MissingFields { fields: HashSet<String>, available_fields: HashSet<String>, }, UnresolvedParam, FailedConstraint { ty: Type<Prim>, constraint: Box<dyn Constraint<Prim>>, }, DynamicLen(TupleLen), UnsupportedFeature(UnsupportedType), UnsupportedType(Type<Prim>), UnsupportedParam, AstConversion(AstConversionError),
}
Expand description

Kinds of errors that can occur during type inference.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

TypeMismatch(Type<Prim>, Type<Prim>)

Trying to unify incompatible types. The first type is LHS, the second one is RHS.

§

TupleLenMismatch

Incompatible tuple lengths.

Fields

§lhs: TupleLen

Length of the LHS. This is the length determined by type annotations for assignments and the number of actually supplied args in function calls.

§rhs: TupleLen

Length of the RHS. This is usually the actual tuple length in assignments and the number of expected args in function calls.

§context: TupleContext

Context in which the error has occurred.

§

UndefinedVar(String)

Undefined variable occurrence.

§

RecursiveType(Type<Prim>)

Trying to unify a type with a type containing it.

§

RepeatedAssignment(String)

Repeated assignment to the same variable in function args or tuple destructuring.

§

InvalidFieldName(String)

Field name is invalid.

§

CannotIndex

Value cannot be indexed (i.e., not a tuple).

§

UnsupportedIndex

Unsupported indexing operation. For example, the receiver type is not known, or it is a tuple with an unknown length, and the type of the element cannot be decided.

§

IndexOutOfBounds

Index is out of bounds for the indexed tuple.

Fields

§index: usize

Index.

§len: TupleLen

Actual tuple length.

§

RepeatedField(String)

Repeated field in object initialization / destructuring.

§

CannotAccessFields

Cannot access fields in a value (i.e., it’s not an object).

§

FieldsMismatch

Field set differs between LHS and RHS, which are both concrete objects.

Fields

§lhs_fields: HashSet<String>

Fields in LHS.

§rhs_fields: HashSet<String>

Fields in RHS.

§

MissingFields

Concrete object does not have required fields.

Fields

§fields: HashSet<String>

Missing fields.

§available_fields: HashSet<String>

Available object fields.

§

UnresolvedParam

Mention of a bounded type or length variable in a type supplied to Substitutions::unify().

Bounded variables are instantiated into free vars automatically during type inference, so this error can only occur with types manually supplied to Substitutions::unify().

§

FailedConstraint

Failure when applying constraint to a type.

Fields

§ty: Type<Prim>

Type that fails constraint requirement.

§constraint: Box<dyn Constraint<Prim>>

Failing constraint.

§

DynamicLen(TupleLen)

Length with the static constraint is actually dynamic (contains UnknownLen::Dynamic).

§

UnsupportedFeature(UnsupportedType)

Language feature not supported by type inference logic.

§

UnsupportedType(Type<Prim>)

Type not supported by type inference logic. For example, a TypeArithmetic or Constraint implementations may return this error if they encounter an unknown Type variant.

§

UnsupportedParam

Unsupported use of type or length params in a function declaration.

Type or length params are currently not supported in type annotations. Here’s an example of code that triggers this error:

identity: (('T,)) -> ('T,) = |x| x;
§

AstConversion(AstConversionError)

Error while instantiating a type from AST.

Implementations§

source§

impl<Prim: PrimitiveType> ErrorKind<Prim>

source

pub fn unsupported<T: Into<UnsupportedType>>(ty: T) -> Self

Creates an error for an lvalue type not supported by the interpreter.

source

pub fn failed_constraint( ty: Type<Prim>, constraint: impl Constraint<Prim> + Clone, ) -> Self

Creates a “failed constraint” error.

Trait Implementations§

source§

impl<Prim: Clone + PrimitiveType> Clone for ErrorKind<Prim>

source§

fn clone(&self) -> ErrorKind<Prim>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Prim: Debug + PrimitiveType> Debug for ErrorKind<Prim>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<Prim: PrimitiveType> Display for ErrorKind<Prim>

source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<Prim: PrimitiveType> Error for ErrorKind<Prim>

source§

fn source(&self) -> Option<&(dyn Error + 'static)>

The lower-level source of this error, if any. Read more
1.0.0 · source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type based access to context intended for error reports. Read more

Auto Trait Implementations§

§

impl<Prim> Freeze for ErrorKind<Prim>
where Prim: Freeze,

§

impl<Prim> !RefUnwindSafe for ErrorKind<Prim>

§

impl<Prim> Send for ErrorKind<Prim>

§

impl<Prim> Sync for ErrorKind<Prim>

§

impl<Prim> Unpin for ErrorKind<Prim>
where Prim: Unpin,

§

impl<Prim> !UnwindSafe for ErrorKind<Prim>

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> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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.