pub enum TypeVar {
Known(Loc<()>, KnownType, Vec<TypeVarID>),
Unknown(Loc<()>, u64, TraitList, MetaType),
}
Expand description
A type variable represents the type of something in the program. It is mapped to expressions by type equations in the TypeState.
When TypeVars are passed externally into TypeState, they must be checked for replacement, as the type inference process might have refined them.
Variants§
Known(Loc<()>, KnownType, Vec<TypeVarID>)
The base type is known and has a list of parameters
Unknown(Loc<()>, u64, TraitList, MetaType)
The type is unknown, but must satisfy the specified traits. When the generic substitution is done, the TypeVars will be carried over to the KnownType type vars
Implementations§
Source§impl TypeVar
impl TypeVar
pub fn into_known(&self, type_state: &TypeState) -> Option<KnownTypeVar>
pub fn insert(self, into: &mut TypeState) -> TypeVarID
pub fn array(loc: Loc<()>, inner: TypeVarID, size: TypeVarID) -> Self
pub fn tuple(loc: Loc<()>, inner: Vec<TypeVarID>) -> Self
pub fn unit(loc: Loc<()>) -> Self
pub fn wire(loc: Loc<()>, inner: TypeVarID) -> Self
pub fn backward( loc: Loc<()>, inner: TypeVarID, type_state: &mut TypeState, ) -> Self
pub fn inverted(loc: Loc<()>, inner: TypeVarID) -> Self
pub fn expect_known<T, U, K, O>(&self, on_known: K, on_unknown: U) -> T
pub fn expect_named<T, E, U, K, O>( &self, on_named: K, on_unknown: U, on_other: O, on_error: E, ) -> T
Sourcepub fn resolve_named_or_inverted(
&self,
inverted_now: bool,
type_state: &TypeState,
) -> ResolvedNamedOrInverted
pub fn resolve_named_or_inverted( &self, inverted_now: bool, type_state: &TypeState, ) -> ResolvedNamedOrInverted
Expect a named type, or TypeVar::Inverted(named), or a recursive inversion. inverted_now is stateful and used to track if we are currently in an inverted context.
pub fn expect_specific_named<T, U, K, O>( &self, name: NameID, on_correct: K, on_unknown: U, on_other: O, ) -> T
Sourcepub fn expect_integer<T, E, U, K, O>(
&self,
on_integer: K,
on_unknown: U,
on_other: O,
on_error: E,
) -> T
pub fn expect_integer<T, E, U, K, O>( &self, on_integer: K, on_unknown: U, on_other: O, on_error: E, ) -> T
Assumes that this type is KnownType::Integer(size) and calls on_integer then. Otherwise calls on_unknown or on_other depending on the type. If the integer is given type params, panics
pub fn display(&self, type_state: &TypeState) -> String
pub fn display_with_meta( &self, display_meta: bool, type_state: &TypeState, ) -> String
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TypeVar
impl<'de> Deserialize<'de> for TypeVar
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Ord for TypeVar
impl Ord for TypeVar
Source§impl PartialOrd for TypeVar
impl PartialOrd for TypeVar
Source§impl WithLocation for TypeVar
impl WithLocation for TypeVar
fn at(self, file_id: usize, span: &impl HasCodespan) -> Loc<Self>where
Self: Sized,
fn between( self, file_id: usize, start: &impl HasCodespan, end: &impl HasCodespan, ) -> Loc<Self>
fn between_locs<T, Y>(self, start: &Loc<T>, end: &Loc<Y>) -> Loc<Self>
fn nowhere(self) -> Loc<Self>where
Self: Sized,
impl Eq for TypeVar
impl StructuralPartialEq for TypeVar
Auto Trait Implementations§
impl Freeze for TypeVar
impl RefUnwindSafe for TypeVar
impl Send for TypeVar
impl Sync for TypeVar
impl Unpin for TypeVar
impl UnwindSafe for TypeVar
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.