|
1 | | -use std::fmt::Debug; |
2 | | -use std::hash::Hash; |
| 1 | +//! An adapter for the existing `polonius-engine` interface. |
| 2 | +
|
| 3 | +use crate::{Db, Dump, FactTypes, StoreTo}; |
3 | 4 |
|
4 | 5 | /// The "facts" which are the basis of the NLL borrow analysis. |
5 | 6 | #[derive(Clone, Debug)] |
@@ -114,16 +115,51 @@ impl<T: FactTypes> Default for AllFacts<T> { |
114 | 115 | } |
115 | 116 | } |
116 | 117 |
|
117 | | -pub trait Atom: |
118 | | - From<usize> + Into<usize> + Copy + Clone + Debug + Eq + Ord + Hash + 'static |
119 | | -{ |
120 | | - fn index(self) -> usize; |
121 | | -} |
122 | | - |
123 | | -pub trait FactTypes: Copy + Clone + Debug { |
124 | | - type Origin: Atom; |
125 | | - type Loan: Atom; |
126 | | - type Point: Atom; |
127 | | - type Variable: Atom; |
128 | | - type Path: Atom; |
| 118 | +impl<T: FactTypes> StoreTo<T> for AllFacts<T> { |
| 119 | + const RELATIONS: crate::Rels = &[ |
| 120 | + "loan_issued_at", |
| 121 | + "universal_region", |
| 122 | + "cfg_edge", |
| 123 | + "loan_killed_at", |
| 124 | + "subset_base", |
| 125 | + "loan_invalidated_at", |
| 126 | + "var_used_at", |
| 127 | + "var_defined_at", |
| 128 | + "var_dropped_at", |
| 129 | + "use_of_var_derefs_origin", |
| 130 | + "drop_of_var_derefs_origin", |
| 131 | + "child_path", |
| 132 | + "path_is_var", |
| 133 | + "path_assigned_at_base", |
| 134 | + "path_moved_at_base", |
| 135 | + "path_accessed_at_base", |
| 136 | + "known_placeholder_subset_base", |
| 137 | + "placeholder", |
| 138 | + ]; |
| 139 | + |
| 140 | + fn store_to_db(self, db: &mut Db<T>, _: &mut Dump<'_>) { |
| 141 | + db.loan_issued_at = Some(self.loan_issued_at.into()); |
| 142 | + db.universal_region = Some(self.universal_region.into_iter().map(|x| (x,)).collect()); |
| 143 | + db.cfg_edge = Some(self.cfg_edge.into()); |
| 144 | + db.loan_killed_at = Some(self.loan_killed_at.into()); |
| 145 | + db.subset_base = Some(self.subset_base.into()); |
| 146 | + db.loan_invalidated_at = Some( |
| 147 | + self.loan_invalidated_at |
| 148 | + .into_iter() |
| 149 | + .map(|(a, b)| (b, a)) |
| 150 | + .collect(), |
| 151 | + ); |
| 152 | + db.var_used_at = Some(self.var_used_at.into()); |
| 153 | + db.var_defined_at = Some(self.var_defined_at.into()); |
| 154 | + db.var_dropped_at = Some(self.var_dropped_at.into()); |
| 155 | + db.use_of_var_derefs_origin = Some(self.use_of_var_derefs_origin.into()); |
| 156 | + db.drop_of_var_derefs_origin = Some(self.drop_of_var_derefs_origin.into()); |
| 157 | + db.child_path = Some(self.child_path.into()); |
| 158 | + db.path_is_var = Some(self.path_is_var.into()); |
| 159 | + db.path_assigned_at_base = Some(self.path_assigned_at_base.into()); |
| 160 | + db.path_moved_at_base = Some(self.path_moved_at_base.into()); |
| 161 | + db.path_accessed_at_base = Some(self.path_accessed_at_base.into()); |
| 162 | + db.known_placeholder_subset_base = Some(self.known_placeholder_subset.into()); |
| 163 | + db.placeholder = Some(self.placeholder.into()); |
| 164 | + } |
129 | 165 | } |
0 commit comments