PathGraph

Struct PathGraph 

Source
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: DiscriminantInfo

Implementations§

Source§

impl<'tcx> PathGraph<'tcx>

Source

pub fn new(tcx: TyCtxt<'tcx>, def_id: DefId) -> PathGraph<'tcx>

Source

pub fn find_scc(&mut self)

Source

pub fn def_id(&self) -> DefId

Source

pub fn tcx(&self) -> TyCtxt<'tcx>

Source

pub fn cfg_block(&self, index: usize) -> &CfgBlock

Source

pub fn cfg_block_mut(&mut self, index: usize) -> &mut CfgBlock

Source

pub fn terminator(&self, index: usize) -> Option<&Terminator<'tcx>>

Retrieve the MIR terminator for the block at index on demand.

Source

pub fn is_cleanup_block(&self, index: usize) -> bool

Source

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).

Source

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.

Source

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.

Source

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.

Source

fn backprop_constraint( &self, cur: usize, local: usize, val: usize, constraints: &mut FxHashMap<usize, usize>, )

Source

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).

Source

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).

Source

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.

Source

fn populate_all_child_sccs(&mut self)

Trait Implementations§

Source§

impl<'tcx> Clone for PathGraph<'tcx>

Source§

fn clone(&self) -> PathGraph<'tcx>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,