pub struct PathGraph<'tcx> {
pub cfg: ControlFlowGraph<'tcx>,
pub block_info: Vec<BlockConstantInfo>,
pub disc_info: DiscriminantInfo,
}Expand description
CFG augmented with per-block constant info and discriminant metadata for path reachability analysis.
PathGraph wraps a ControlFlowGraph and adds block-indexed data
that track assignments, constants, and copy chains. These are used by
check_transition to update a set of
discriminant constraints while traversing the CFG, enabling early
pruning of infeasible SwitchInt branches during path enumeration.
Fields§
§cfg: ControlFlowGraph<'tcx>§block_info: Vec<BlockConstantInfo>§disc_info: DiscriminantInfoImplementations§
Source§impl<'tcx> PathGraph<'tcx>
impl<'tcx> PathGraph<'tcx>
pub fn new(tcx: TyCtxt<'tcx>, def_id: DefId) -> PathGraph<'tcx>
pub fn find_scc(&mut self)
pub fn def_id(&self) -> DefId
pub fn tcx(&self) -> TyCtxt<'tcx>
pub fn cfg_block(&self, index: usize) -> &CfgBlock
pub fn cfg_block_mut(&mut self, index: usize) -> &mut CfgBlock
Sourcepub fn terminator(&self, index: usize) -> Option<&Terminator<'tcx>>
pub fn terminator(&self, index: usize) -> Option<&Terminator<'tcx>>
Retrieve the MIR terminator for the block at index on demand.
pub fn is_cleanup_block(&self, index: usize) -> bool
Sourcefn get_variant_count(&self, local: usize) -> Option<usize>
fn get_variant_count(&self, local: usize) -> Option<usize>
Get the number of variants for a constraint local.
First checks the pre-populated variant_count_of hashmap,
then falls back to the local’s declared type (for ADT locals
that gained their type through field projections in nested
destructuring patterns rather than explicit construction).
Sourcepub fn check_transition(
&self,
cur: usize,
next: usize,
constraints: &mut FxHashMap<usize, usize>,
) -> bool
pub fn check_transition( &self, cur: usize, next: usize, constraints: &mut FxHashMap<usize, usize>, ) -> bool
Check a single transition cur -> next for reachability and update
discriminant constraints. Returns false if the transition is
provably unreachable.
Sourcefn check_switch_transition(
&self,
cur: usize,
next: usize,
constraints: &mut FxHashMap<usize, usize>,
) -> bool
fn check_switch_transition( &self, cur: usize, next: usize, constraints: &mut FxHashMap<usize, usize>, ) -> bool
Check whether cur → next is a valid SwitchInt transition given
current discriminant constraints. Returns false when the transition
contradicts a known discriminant value. Also records newly learned
constraints from the taken branch into constraints.
Sourcefn learn_constraint_with_backprop(
&self,
cur: usize,
constraint_local: Option<usize>,
targets: &SwitchTargets,
next: usize,
constraints: &mut FxHashMap<usize, usize>,
)
fn learn_constraint_with_backprop( &self, cur: usize, constraint_local: Option<usize>, targets: &SwitchTargets, next: usize, constraints: &mut FxHashMap<usize, usize>, )
After learning a constraint for a discriminant local, propagate the constraint backward through the copy chain so that source locals also receive the value. This prevents losing track of the constraint when the destination temporary is reassigned on loop back-edges.
fn backprop_constraint( &self, cur: usize, local: usize, val: usize, constraints: &mut FxHashMap<usize, usize>, )
Sourcefn infer_otherwise_value(
&self,
targets: &SwitchTargets,
discr_local: usize,
) -> Option<usize>
fn infer_otherwise_value( &self, targets: &SwitchTargets, discr_local: usize, ) -> Option<usize>
For the “otherwise” branch of a SwitchInt, try to infer the single
concrete value that the discriminant must have (because all other
possible values are covered by explicit targets).
Sourcefn is_unwind_target(&self, cur: usize, next: usize) -> bool
fn is_unwind_target(&self, cur: usize, next: usize) -> bool
Check whether next is an unwind target reachable from cur via a
call or drop terminator (may not be recorded as a normal CFG successor).
Sourcefn populate_child_sccs(&mut self, enter: usize)
fn populate_child_sccs(&mut self, enter: usize)
Populate the child_sccs field for a given SCC entry block, then
recurse into those child SCCs. Called eagerly from find_scc() so
that enumeration can be purely read-only on the graph.
fn populate_all_child_sccs(&mut self)
Trait Implementations§
Auto Trait Implementations§
impl<'tcx> Freeze for PathGraph<'tcx>
impl<'tcx> !RefUnwindSafe for PathGraph<'tcx>
impl<'tcx> !Send for PathGraph<'tcx>
impl<'tcx> !Sync for PathGraph<'tcx>
impl<'tcx> Unpin for PathGraph<'tcx>
impl<'tcx> !UnwindSafe for PathGraph<'tcx>
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,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more