Skip to main content

Cfg

Trait Cfg 

Source
pub trait Cfg {
    type NodeId: Copy + Eq + Hash + Ord + Debug;
    type Hasher: BuildHasher + Default;

    // Required method
    fn successors(
        &self,
        n: Self::NodeId,
    ) -> impl Iterator<Item = Self::NodeId> + '_;
}
Expand description

A minimal control-flow-graph view: the successor relation on node ids.

Dominator and post-dominator analysis need only two things from a graph: the successors of a node id, and a deterministic Hasher for their internal node-keyed maps. Bounding those algorithms on Cfg instead of the full Graph lets a caller expose just a successor relation — e.g. a checked-out function’s CFG read through a Copy host handle, which cannot hand out the &'graph Self::Graph that Node requires.

Every Graph is a Cfg via the blanket impl below, so existing graph consumers keep working unchanged.

Required Associated Types§

Source

type NodeId: Copy + Eq + Hash + Ord + Debug

Source

type Hasher: BuildHasher + Default

Hasher backing the analyses’ node-keyed maps. Picking a fixed-seed hasher (e.g. FxBuildHasher) keeps successors iteration — and thus the derived dominator structures — deterministic across runs, whereas the std default (RandomState) reseeds per process.

Required Methods§

Source

fn successors(&self, n: Self::NodeId) -> impl Iterator<Item = Self::NodeId> + '_

The successors of n (the targets of its outgoing edges).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<G: Graph> Cfg for G

Source§

type NodeId = <G as Graph>::NodeId

Source§

type Hasher = <G as Graph>::Hasher