pub enum Constraint {
Equal(InferType, InferType, Span),
IsSigned(InferType, Span),
IsInteger(InferType, Span),
IsUnsigned(InferType, Span),
IsNumeric(InferType, Span),
}Expand description
A type constraint generated during analysis.
Constraints express relationships between types that must hold. They are collected during constraint generation and then solved during unification.
Variants§
Equal(InferType, InferType, Span)
Two types must be equal: τ₁ = τ₂.
This is the primary constraint type. Generated for:
- Binary operations (both operands must have same type)
- Assignments (value type must match variable type)
- Function calls (argument types must match parameter types)
- Return statements (returned type must match declared return type)
IsSigned(InferType, Span)
Type must be a signed integer: τ ∈ {i8, i16, i32, i64}.
Generated for unary negation which requires signed types. Unsigned integers cannot be negated.
IsInteger(InferType, Span)
Type must be an integer (signed or unsigned): τ ∈ {i8, i16, i32, i64, u8, u16, u32, u64}.
Generated for bitwise NOT which works on any integer type.
IsUnsigned(InferType, Span)
Type must be an unsigned integer: τ ∈ {u8, u16, u32, u64}.
Generated for array indexing which requires non-negative indices.
IsNumeric(InferType, Span)
Type must be numeric (integer or float): τ ∈ {i8..i64, u8..u64, isize, usize, f16..f64}.
Generated for arithmetic operators (+, -, *, /, %) which work on both integer and floating-point types.
Implementations§
Source§impl Constraint
impl Constraint
Sourcepub fn equal(lhs: InferType, rhs: InferType, span: Span) -> Self
pub fn equal(lhs: InferType, rhs: InferType, span: Span) -> Self
Create an equality constraint.
Sourcepub fn is_integer(ty: InferType, span: Span) -> Self
pub fn is_integer(ty: InferType, span: Span) -> Self
Create a “must be integer” constraint.
Sourcepub fn is_unsigned(ty: InferType, span: Span) -> Self
pub fn is_unsigned(ty: InferType, span: Span) -> Self
Create a “must be unsigned” constraint.
Sourcepub fn is_numeric(ty: InferType, span: Span) -> Self
pub fn is_numeric(ty: InferType, span: Span) -> Self
Create a “must be numeric” constraint (integer or float).
Trait Implementations§
Source§impl Clone for Constraint
impl Clone for Constraint
Source§fn clone(&self) -> Constraint
fn clone(&self) -> Constraint
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for Constraint
impl RefUnwindSafe for Constraint
impl Send for Constraint
impl Sync for Constraint
impl Unpin for Constraint
impl UnwindSafe for Constraint
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<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].