pub struct Context<'brand> { /* private fields */ }
Expand description
Type inference context, or handle to a context.
Can be cheaply cloned with Context::shallow_clone
. These clones will
refer to the same underlying type inference context, and can be used as
handles to each other. The derived Context::clone
has the same effect.
There is currently no way to create an independent context with the same type inference variables (i.e. a deep clone). If you need this functionality, please file an issue.
Implementations§
Source§impl<'brand> Context<'brand>
impl<'brand> Context<'brand>
Sourcepub fn with_context<R, F>(fun: F) -> R
pub fn with_context<R, F>(fun: F) -> R
Creates a scope with a new empty type inference context.
Sourcepub fn new(token: GhostToken<'brand>) -> Self
pub fn new(token: GhostToken<'brand>) -> Self
Creates a new empty type inference context.
Sourcepub fn alloc_free(&self, name: String) -> BoundRef<'brand>
pub fn alloc_free(&self, name: String) -> BoundRef<'brand>
Allocate a new free type bound, and return a reference to it.
Sourcepub fn alloc_unit(&self) -> BoundRef<'brand>
pub fn alloc_unit(&self) -> BoundRef<'brand>
Allocate a new unit type bound, and return a reference to it.
Sourcepub fn alloc_complete(&self, data: Arc<Final>) -> BoundRef<'brand>
pub fn alloc_complete(&self, data: Arc<Final>) -> BoundRef<'brand>
Allocate a new unit type bound, and return a reference to it.
Sourcepub fn alloc_sum(
&self,
left: Type<'brand>,
right: Type<'brand>,
) -> BoundRef<'brand>
pub fn alloc_sum( &self, left: Type<'brand>, right: Type<'brand>, ) -> BoundRef<'brand>
Allocate a new sum-type bound, and return a reference to it.
Sourcepub fn alloc_product(
&self,
left: Type<'brand>,
right: Type<'brand>,
) -> BoundRef<'brand>
pub fn alloc_product( &self, left: Type<'brand>, right: Type<'brand>, ) -> BoundRef<'brand>
Allocate a new product-type bound, and return a reference to it.
Sourcepub fn shallow_clone(&self) -> Self
pub fn shallow_clone(&self) -> Self
Creates a new handle to the context.
This handle holds a reference to the underlying context and will keep it alive. The context will only be dropped once all handles, including the original context object, are dropped.
Sourcepub fn check_eq(&self, other: &Self) -> Result<(), Error>
pub fn check_eq(&self, other: &Self) -> Result<(), Error>
Checks whether two inference contexts are equal, and returns an error if not.
Sourcepub fn bind_product(
&self,
existing: &Type<'brand>,
prod_l: &Type<'brand>,
prod_r: &Type<'brand>,
hint: &'static str,
) -> Result<(), Error>
pub fn bind_product( &self, existing: &Type<'brand>, prod_l: &Type<'brand>, prod_r: &Type<'brand>, hint: &'static str, ) -> Result<(), Error>
Binds the type to a product bound formed by the two inner types. If this fails, attach the provided hint to the error.
Fails if the type has an existing incompatible bound.