Prevent modifications without an undo log
This commit is contained in:
parent
6e06535468
commit
729d16f010
4 changed files with 25 additions and 25 deletions
|
@ -155,13 +155,13 @@ pub struct InferCtxtInner<'tcx> {
|
|||
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
|
||||
|
@ -212,9 +212,9 @@ impl<'tcx> InferCtxtInner<'tcx> {
|
|||
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![],
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ pub struct RegionConstraintStorage<'tcx> {
|
|||
/// is iterating to a fixed point, because otherwise we sometimes
|
||||
/// would wind up with a fresh stream of region variables that
|
||||
/// have been equated but appear distinct.
|
||||
pub(super) unification_table: ut::UnificationStorage<ty::RegionVid>,
|
||||
pub(super) unification_table: ut::UnificationTableStorage<ty::RegionVid>,
|
||||
|
||||
/// a flag set to true when we perform any unifications; this is used
|
||||
/// to micro-optimize `take_and_reset_data`
|
||||
|
|
|
@ -54,12 +54,12 @@ impl<'tcx> Rollback<UndoLog<'tcx>> for TypeVariableStorage<'tcx> {
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -78,15 +78,15 @@ pub struct TypeVariableStorage<'tcx> {
|
|||
/// 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>,
|
||||
}
|
||||
|
@ -159,9 +159,9 @@ pub(crate) struct Delegate;
|
|||
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(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ impl<'tcx> TypeVariableTable<'tcx, '_> {
|
|||
/// 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.
|
||||
|
@ -188,7 +188,7 @@ impl<'tcx> TypeVariableTable<'tcx, '_> {
|
|||
/// 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`.
|
||||
|
@ -330,15 +330,15 @@ impl<'tcx> TypeVariableTable<'tcx, '_> {
|
|||
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.
|
||||
|
@ -351,7 +351,7 @@ impl<'tcx> TypeVariableTable<'tcx, '_> {
|
|||
(
|
||||
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(),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -98,9 +98,9 @@ impl<'tcx> From<traits::UndoLog<'tcx>> for UndoLog<'tcx> {
|
|||
|
||||
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>)>,
|
||||
|
|
Loading…
Add table
Reference in a new issue