use crate::verify::{
contract,
def_use::RelevantPlaces,
helpers::CheckpointLocation,
path_extractor::{Path, PathStep},
};
use rustc_middle::mir::BasicBlock;
#[derive(Clone, Debug)]
pub struct RelevantMirItems<'tcx> {
pub checkpoint: CheckpointLocation,
pub property: contract::Property<'tcx>,
pub path: Path,
pub items: Vec<BackwardItem<'tcx>>,
pub roots: RelevantPlaces,
}
impl<'tcx> RelevantMirItems<'tcx> {
pub fn push(&mut self, item: BackwardItem<'tcx>) {
self.items.push(item);
}
pub fn is_empty(&self) -> bool {
self.items.is_empty()
}
}
#[derive(Clone, Debug)]
pub enum BackwardItem<'tcx> {
Statement {
block: BasicBlock,
statement_index: usize,
kind: KeepReason,
},
Terminator { block: BasicBlock, kind: KeepReason },
PathStep { step: PathStep, kind: KeepReason },
ContractFact { property: contract::Property<'tcx> },
Forget { reason: ForgetReason },
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum KeepReason {
Definition,
PathCondition,
PointerFlow,
RuntimeCheck,
Checkpoint,
LoopExit,
Invalidation,
UnknownEffect,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum ForgetReason {
UnknownCall,
SccWithoutSummary,
MayAliasWrite,
UnsupportedEffect,
}