pub enum InferType {
Concrete(Type),
Var(TypeVarId),
IntLiteral,
FloatLiteral,
Array {
element: Box<InferType>,
length: u64,
},
}Expand description
Internal type representation during inference.
This is separate from the final Type enum to support type variables
and the special IntLiteral type. After unification, all InferTypes
are resolved to concrete Types.
Variants§
Concrete(Type)
A concrete type (maps directly to Type enum).
Var(TypeVarId)
A type variable (unknown, to be solved).
IntLiteral
An integer literal type.
Integer literals can unify with any integer type (i8-i64, u8-u64).
When unified with a concrete integer type, the literal takes that type.
If unconstrained at the end of inference, defaults to i32.
FloatLiteral
A floating-point literal type.
Float literals can unify with any float type (f16, f32, f64).
If unconstrained at the end of inference, defaults to f64.
Array
An array type during inference.
Unlike Concrete(Type::new_array(id)), this stores the element type as an
InferType so we can handle cases where the element type is still a
type variable. After unification, these are converted to Type::Array.
Implementations§
Source§impl InferType
impl InferType
Sourcepub fn int_literal() -> Self
pub fn int_literal() -> Self
Create an integer literal type.
Sourcepub fn is_concrete(&self) -> bool
pub fn is_concrete(&self) -> bool
Check if this is a concrete type.
Sourcepub fn is_int_literal(&self) -> bool
pub fn is_int_literal(&self) -> bool
Check if this is an integer literal type.
Sourcepub fn as_concrete(&self) -> Option<Type>
pub fn as_concrete(&self) -> Option<Type>
Get the concrete type if this is Concrete.
Trait Implementations§
impl Eq for InferType
impl StructuralPartialEq for InferType
Auto Trait Implementations§
impl Freeze for InferType
impl RefUnwindSafe for InferType
impl Send for InferType
impl Sync for InferType
impl Unpin for InferType
impl UnwindSafe for InferType
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,
§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.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
MaybeRef].