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
8/// The results of a dataflow analysis that has converged to fixpoint. It only holds the domain
9/// values at the entry of each basic block. Domain values in other parts of the block are
10/// recomputed on the fly by visitors (i.e. `ResultsCursor`, or `ResultsVisitor` impls).
11pub type Results<D> = IndexVec<BasicBlock, D>;
12
13/// Utility type used in a few places where it's convenient to bundle an analysis with its results.
14pub struct AnalysisAndResults<'tcx, A>
15where
16    A: Analysis<'tcx>,
17{
18    pub analysis: A,
19    pub results: Results<A::Domain>,
20}
21
22impl<'tcx, A> AnalysisAndResults<'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.analysis, self.results)
29    }
30}