pub struct FlowFacts {
pub type_narrowings: FxHashMap<String, TypeId>,
pub definite_assignments: FxHashSet<String>,
pub tdz_violations: FxHashSet<String>,
}Expand description
Flow facts that represent the state of variables at a specific program point.
This structure bridges the checker’s flow analysis and the solver’s type system by tracking what we know about variables at a given control flow point.
Fields§
§type_narrowings: FxHashMap<String, TypeId>Type narrowings: maps variable name to its narrowed type
definite_assignments: FxHashSet<String>Variables that are definitely assigned at this point
tdz_violations: FxHashSet<String>Variables that violate TDZ (used before declaration)
Implementations§
Source§impl FlowFacts
impl FlowFacts
Sourcepub fn add_narrowing(&mut self, variable: String, narrowed_type: TypeId)
pub fn add_narrowing(&mut self, variable: String, narrowed_type: TypeId)
Add a type narrowing for a variable
Sourcepub fn mark_definitely_assigned(&mut self, variable: String)
pub fn mark_definitely_assigned(&mut self, variable: String)
Mark a variable as definitely assigned
Sourcepub fn mark_tdz_violation(&mut self, variable: String)
pub fn mark_tdz_violation(&mut self, variable: String)
Mark a variable as having a TDZ violation
Sourcepub fn is_definitely_assigned(&self, variable: &str) -> bool
pub fn is_definitely_assigned(&self, variable: &str) -> bool
Check if a variable is definitely assigned
Sourcepub fn has_tdz_violation(&self, variable: &str) -> bool
pub fn has_tdz_violation(&self, variable: &str) -> bool
Check if a variable has a TDZ violation
Sourcepub fn get_narrowed_type(&self, variable: &str) -> Option<TypeId>
pub fn get_narrowed_type(&self, variable: &str) -> Option<TypeId>
Get the narrowed type for a variable (if any)
Sourcepub fn merge(&self, other: &Self) -> Self
pub fn merge(&self, other: &Self) -> Self
Merge two flow fact sets (for join points in control flow)
At control flow join points (e.g., after if/else), we:
- Keep only narrowings that are present in both branches (intersection)
- Keep only definite assignments that are present in both branches
- Keep only TDZ violations that are present in both branches (intersection)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FlowFacts
impl RefUnwindSafe for FlowFacts
impl Send for FlowFacts
impl Sync for FlowFacts
impl Unpin for FlowFacts
impl UnsafeUnpin for FlowFacts
impl UnwindSafe for FlowFacts
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
Mutably borrows from an owned value. Read more