Skip to main content

UnionFindTable

Struct UnionFindTable 

Source
pub struct UnionFindTable { /* private fields */ }
Expand description

Flat union-find inference variable table reusable across functions via Self::clear.

Implementations§

Source§

impl UnionFindTable

Source

pub fn with_capacity(cap: usize) -> Self

Source

pub fn clear(&mut self)

Source

pub fn var_count(&self) -> usize

Source

pub fn new_var( &mut self, arena: &mut InferTyArena, kind: TyVarKind, ) -> (TyVarId, InferTyId)

Allocates a fresh inference variable and its InferTyId wrapper inside arena.

Source

pub fn start_snapshot(&mut self) -> InferSnapshot

Source

pub fn commit(&mut self, snap: InferSnapshot)

Source

pub fn rollback_to(&mut self, snap: InferSnapshot)

Source

pub fn probe_var( &mut self, var: TyVarId, ) -> Result<InferTyId, (TyVarId, TyVarKind, u8, InferTyId)>

Finds the current representative of var with snapshot-aware path halving/compression.

Source

pub fn probe_var_imm( &self, var: TyVarId, ) -> Result<InferTyId, (TyVarId, TyVarKind)>

Immutable read without path compression (safe for diagnostics and assertions).

Source

pub fn shallow_resolve( &mut self, arena: &InferTyArena, ty: InferTyId, ) -> InferTyId

Peels chained Infer(v) indirections until reaching a concrete type or an unbound root Infer(root).

Source

pub fn occurs_in( &mut self, arena: &InferTyArena, needle_root: TyVarId, ty: InferTyId, ) -> bool

Checks whether needle_root appears anywhere inside ty (O(1) fast path when !has_infer()).

Source

pub fn deep_resolve( &mut self, arena: &mut InferTyArena, ty: InferTyId, fallback_unbound: bool, ) -> InferTyId

Recursively substitutes solved inference variables (O(1) when !has_infer()). When fallback_unbound is true, maps {integer} -> i32, {float} -> f64, _ -> {unknown}.

Trait Implementations§

Source§

impl Debug for UnionFindTable

Source§

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

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

impl Default for UnionFindTable

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for UnionFindTable

§

impl Freeze for UnionFindTable
where *const u8 is !null: Freeze, PhantomData<VarSlot>: Freeze, PhantomData<UndoEntry>: Freeze,

§

impl Move for UnionFindTable

§

impl RefUnwindSafe for UnionFindTable

§

impl Send for UnionFindTable
where RawVecInner: Send,

§

impl Sync for UnionFindTable
where RawVecInner: Sync,

§

impl Unpin for UnionFindTable
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for UnionFindTable
where *const u8 is !null: UnsafeUnpin, PhantomData<VarSlot>: UnsafeUnpin, PhantomData<UndoEntry>: UnsafeUnpin,

§

impl UnwindSafe for UnionFindTable
where RawVecInner: UnwindSafe,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.