pub enum Type {
Show 15 variants
Bottom,
Any,
Primitive(BitFlags<Typ>),
Ref(TypeRef),
Fn(Arc<FnType>),
Set(Arc<[Type]>),
TVar(TVar),
Error(Arc<Type>),
Array(Arc<Type>),
ByRef(Arc<Type>),
Tuple(Arc<[Type]>),
Struct(Arc<[(ArcStr, Type)]>),
Variant(ArcStr, Arc<[Type]>),
Map {
key: Arc<Type>,
value: Arc<Type>,
},
Abstract {
id: AbstractId,
params: Arc<[Type]>,
},
}Variants§
Bottom
Any
Primitive(BitFlags<Typ>)
Ref(TypeRef)
Fn(Arc<FnType>)
Set(Arc<[Type]>)
TVar(TVar)
Error(Arc<Type>)
Array(Arc<Type>)
ByRef(Arc<Type>)
Tuple(Arc<[Type]>)
Struct(Arc<[(ArcStr, Type)]>)
Variant(ArcStr, Arc<[Type]>)
Map
Abstract
Implementations§
Source§impl Type
impl Type
Source§impl Type
impl Type
pub fn could_match(&self, env: &Env, t: &Self) -> Result<bool>
pub fn sig_matches( &self, env: &Env, impl_type: &Self, adts: &FxHashMap<AbstractId, Type>, ) -> Result<()>
Source§impl Type
impl Type
Sourcepub fn resolve_tvars(&self) -> Self
pub fn resolve_tvars(&self) -> Self
Deep-clone the type tree, replacing every bound TVar with its concrete binding (recursively). Unbound TVars are kept as fresh named TVars. This produces a snapshot that is independent of the original TVar cells.
Source§impl Type
impl Type
pub fn unfreeze_tvars(&self)
Sourcepub fn alias_tvars(&self, known: &mut FxHashMap<ArcStr, TVar>)
pub fn alias_tvars(&self, known: &mut FxHashMap<ArcStr, TVar>)
alias type variables with the same name to each other
pub fn collect_tvars(&self, known: &mut FxHashMap<ArcStr, TVar>)
pub fn check_tvars_declared(&self, declared: &FxHashSet<ArcStr>) -> Result<()>
pub fn has_unbound(&self) -> bool
Sourcepub fn reset_tvars(&self) -> Type
pub fn reset_tvars(&self) -> Type
return a copy of self with all type variables unbound and unaliased. self will not be modified
Sourcepub fn replace_tvars(&self, known: &FxHashMap<ArcStr, Self>) -> Type
pub fn replace_tvars(&self, known: &FxHashMap<ArcStr, Self>) -> Type
return a copy of self with every TVar named in known replaced with the corresponding type. TVars not in known are replaced with fresh TVars using unique names to avoid entanglement with the caller’s TVars that happen to share the same name.
Source§impl Type
impl Type
pub fn empty_tvar() -> Self
pub fn is_defined(&self) -> bool
pub fn lookup_ref(&self, env: &Env) -> Result<Type>
Sourcepub fn record_ide_refs(&self, env: &Env, fallback_scope: &ModPath)
pub fn record_ide_refs(&self, env: &Env, fallback_scope: &ModPath)
Walk this type tree and, for every Type::Ref carrying
parser-populated pos/ori, push a TypeRefSite to the
IDE side-channel. Used at typedef-registration time so
references inside typedef bodies (which the type system
never auto-derefs) still show up in find-references results.
Caller is responsible for gating on env.lsp_mode; this
method recurses unconditionally once entered.
pub fn any() -> Self
pub fn boolean() -> Self
pub fn number() -> Self
pub fn int() -> Self
pub fn uint() -> Self
Sourcepub fn strip_error(&self, env: &Env) -> Option<Self>
pub fn strip_error(&self, env: &Env) -> Option<Self>
remove the outer error type and return the inner payload, fail if self isn’t an error or contains non error types
pub fn is_bot(&self) -> bool
pub fn with_deref<R, F: FnOnce(Option<&Self>) -> R>(&self, f: F) -> R
pub fn scope_refs(&self, scope: &ModPath) -> Type
Trait Implementations§
Source§impl Ord for Type
impl Ord for Type
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Type
impl PartialOrd for Type
Source§impl PrettyDisplay for Type
impl PrettyDisplay for Type
Source§fn fmt_pretty_inner(&self, buf: &mut PrettyBuf) -> Result
fn fmt_pretty_inner(&self, buf: &mut PrettyBuf) -> Result
Source§fn fmt_pretty(&self, buf: &mut PrettyBuf) -> Result
fn fmt_pretty(&self, buf: &mut PrettyBuf) -> Result
impl Eq for Type
impl StructuralPartialEq for Type
Auto Trait Implementations§
impl Freeze for Type
impl !RefUnwindSafe for Type
impl Send for Type
impl Sync for Type
impl Unpin for Type
impl UnsafeUnpin for Type
impl !UnwindSafe for Type
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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.Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more