use super::{bug_records::*, drop::*};
use crate::analysis::{
alias_analysis::default::graph::AliasGraph, ownedheap_analysis::OHAResultMap,
};
use rustc_middle::ty::TyCtxt;
use rustc_span::def_id::DefId;
use std::{fmt, vec::Vec};
pub struct SafeDropGraph<'tcx> {
pub alias_graph: AliasGraph<'tcx>,
pub bug_records: BugRecords,
pub drop_record: Vec<DropRecord>,
pub adt_owner: OHAResultMap,
}
impl<'tcx> SafeDropGraph<'tcx> {
pub fn new(tcx: TyCtxt<'tcx>, def_id: DefId, adt_owner: OHAResultMap) -> Self {
let alias_graph = AliasGraph::new(tcx, def_id);
let mut drop_record = Vec::<DropRecord>::new();
for v in &alias_graph.values {
drop_record.push(DropRecord::false_record(v.index));
}
SafeDropGraph {
alias_graph,
bug_records: BugRecords::new(),
drop_record,
adt_owner,
}
}
}
impl<'tcx> std::fmt::Display for SafeDropGraph<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "SafeDropGraph {{")?;
writeln!(f, " AliasGraph: {}", self.alias_graph)?;
write!(f, "}}")
}
}