rustc_mir_dataflow/framework/
results.rs

1//! Dataflow analysis results.
2
3use rustc_index::IndexVec;
4use rustc_middle::mir::{BasicBlock, Body};
5
6use super::{Analysis, ResultsCursor};
7
8pub type EntryStates<D> = IndexVec<BasicBlock, D>;
9
10/// The results of a dataflow analysis that has converged to fixpoint. It holds the domain values
11/// (states) at the entry of each basic block. Domain values in other parts of the block are
12/// recomputed on the fly by visitors (i.e. `ResultsCursor`, or `ResultsVisitor` impls). The
13/// analysis is also present because it's often needed alongside the entry states.
14pub struct Results<'tcx, A>
15where
16    A: Analysis<'tcx>,
17{
18    pub analysis: A,
19    pub entry_states: EntryStates<A::Domain>,
20}
21
22impl<'tcx, A> Results<'tcx, A>
23where
24    A: Analysis<'tcx>,
25{
26    /// Creates a `ResultsCursor` that takes ownership of `self`.
27    pub fn into_results_cursor<'mir>(self, body: &'mir Body<'tcx>) -> ResultsCursor<'mir, 'tcx, A> {
28        ResultsCursor::new_owning(body, self)
29    }
30}