type_variables: type_variable::TypeVariableStorage<'tcx>,
/// Map from const parameter variable to the kind of const it represents.
- const_unification_table: ut::UnificationStorage<ty::ConstVid<'tcx>>,
+ const_unification_table: ut::UnificationTableStorage<ty::ConstVid<'tcx>>,
/// Map from integral variable to the kind of integer it represents.
- int_unification_table: ut::UnificationStorage<ty::IntVid>,
+ int_unification_table: ut::UnificationTableStorage<ty::IntVid>,
/// Map from floating variable to the kind of float it represents.
- float_unification_table: ut::UnificationStorage<ty::FloatVid>,
+ float_unification_table: ut::UnificationTableStorage<ty::FloatVid>,
/// Tracks the set of region variables and the constraints between them.
/// This is initially `Some(_)` but when
projection_cache: Default::default(),
type_variables: type_variable::TypeVariableStorage::new(),
undo_log: InferCtxtUndoLogs::default(),
- const_unification_table: ut::UnificationStorage::new(),
- int_unification_table: ut::UnificationStorage::new(),
- float_unification_table: ut::UnificationStorage::new(),
+ const_unification_table: ut::UnificationTableStorage::new(),
+ int_unification_table: ut::UnificationTableStorage::new(),
+ float_unification_table: ut::UnificationTableStorage::new(),
region_constraints: Some(RegionConstraintStorage::new()),
region_obligations: vec![],
}
}
pub struct TypeVariableStorage<'tcx> {
- values: Vec<TypeVariableData>,
+ values: sv::SnapshotVecStorage<Delegate>,
/// Two variables are unified in `eq_relations` when we have a
/// constraint `?X == ?Y`. This table also stores, for each key,
/// the known value.
- eq_relations: ut::UnificationStorage<TyVidEqKey<'tcx>>,
+ eq_relations: ut::UnificationTableStorage<TyVidEqKey<'tcx>>,
/// Two variables are unified in `sub_relations` when we have a
/// constraint `?X <: ?Y` *or* a constraint `?Y <: ?X`. This second
/// This is reasonable because, in Rust, subtypes have the same
/// "skeleton" and hence there is no possible type such that
/// (e.g.) `Box<?3> <: ?3` for any `?3`.
- sub_relations: ut::UnificationStorage<ty::TyVid>,
+ sub_relations: ut::UnificationTableStorage<ty::TyVid>,
}
pub struct TypeVariableTable<'tcx, 'a> {
- values: &'a mut Vec<TypeVariableData>,
+ values: &'a mut sv::SnapshotVecStorage<Delegate>,
- eq_relations: &'a mut ut::UnificationStorage<TyVidEqKey<'tcx>>,
+ eq_relations: &'a mut ut::UnificationTableStorage<TyVidEqKey<'tcx>>,
- sub_relations: &'a mut ut::UnificationStorage<ty::TyVid>,
+ sub_relations: &'a mut ut::UnificationTableStorage<ty::TyVid>,
undo_log: &'a mut InferCtxtUndoLogs<'tcx>,
}
impl<'tcx> TypeVariableStorage<'tcx> {
pub fn new() -> TypeVariableStorage<'tcx> {
TypeVariableStorage {
- values: Vec::new(),
- eq_relations: ut::UnificationStorage::new(),
- sub_relations: ut::UnificationStorage::new(),
+ values: sv::SnapshotVecStorage::new(),
+ eq_relations: ut::UnificationTableStorage::new(),
+ sub_relations: ut::UnificationTableStorage::new(),
}
}
/// Note that this function does not return care whether
/// `vid` has been unified with something else or not.
pub fn var_diverges(&self, vid: ty::TyVid) -> bool {
- self.values.get(vid.index as usize).unwrap().diverging
+ self.values.get(vid.index as usize).diverging
}
/// Returns the origin that was given when `vid` was created.
/// Note that this function does not return care whether
/// `vid` has been unified with something else or not.
pub fn var_origin(&self, vid: ty::TyVid) -> &TypeVariableOrigin {
- &self.values.get(vid.index as usize).unwrap().origin
+ &self.values.get(vid.index as usize).origin
}
/// Records that `a == b`, depending on `dir`.
fn values(
&mut self,
) -> sv::SnapshotVec<Delegate, &mut Vec<TypeVariableData>, &mut InferCtxtUndoLogs<'tcx>> {
- sv::SnapshotVec::with_log(self.values, self.undo_log)
+ self.values.with_log(self.undo_log)
}
fn eq_relations(&mut self) -> super::UnificationTable<'_, 'tcx, TyVidEqKey<'tcx>> {
- ut::UnificationTable::with_log(self.eq_relations, self.undo_log)
+ self.eq_relations.with_log(self.undo_log)
}
fn sub_relations(&mut self) -> super::UnificationTable<'_, 'tcx, ty::TyVid> {
- ut::UnificationTable::with_log(self.sub_relations, self.undo_log)
+ self.sub_relations.with_log(self.undo_log)
}
/// Returns a range of the type variables created during the snapshot.
(
range.start..range.end,
(range.start.index..range.end.index)
- .map(|index| self.values.get(index as usize).unwrap().origin)
+ .map(|index| self.values.get(index as usize).origin)
.collect(),
)
}
pub(super) struct RollbackView<'tcx, 'a> {
pub(super) type_variables: &'a mut type_variable::TypeVariableStorage<'tcx>,
- pub(super) const_unification_table: &'a mut ut::UnificationStorage<ty::ConstVid<'tcx>>,
- pub(super) int_unification_table: &'a mut ut::UnificationStorage<ty::IntVid>,
- pub(super) float_unification_table: &'a mut ut::UnificationStorage<ty::FloatVid>,
+ pub(super) const_unification_table: &'a mut ut::UnificationTableStorage<ty::ConstVid<'tcx>>,
+ pub(super) int_unification_table: &'a mut ut::UnificationTableStorage<ty::IntVid>,
+ pub(super) float_unification_table: &'a mut ut::UnificationTableStorage<ty::FloatVid>,
pub(super) region_constraints: &'a mut RegionConstraintStorage<'tcx>,
pub(super) projection_cache: &'a mut traits::ProjectionCacheStorage<'tcx>,
pub(super) region_obligations: &'a mut Vec<(hir::HirId, RegionObligation<'tcx>)>,