use rustc_ast::ast;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::Lrc;
-use rustc_data_structures::undo_log::{Rollback, Snapshots};
+use rustc_data_structures::undo_log::Rollback;
use rustc_data_structures::unify as ut;
use rustc_errors::DiagnosticBuilder;
use rustc_hir as hir;
/// We instantiate `UnificationTable` with `bounds<Ty>` because the types
/// that might instantiate a general type variable have an order,
/// represented by its upper and lower bounds.
- type_variables: type_variable::TypeVariableStorage<'tcx>,
+ type_variable_storage: type_variable::TypeVariableStorage<'tcx>,
/// Map from const parameter variable to the kind of const it represents.
- const_unification_table: ut::UnificationTableStorage<ty::ConstVid<'tcx>>,
+ const_unification_storage: ut::UnificationTableStorage<ty::ConstVid<'tcx>>,
/// Map from integral variable to the kind of integer it represents.
- int_unification_table: ut::UnificationTableStorage<ty::IntVid>,
+ int_unification_storage: ut::UnificationTableStorage<ty::IntVid>,
/// Map from floating variable to the kind of float it represents.
- float_unification_table: ut::UnificationTableStorage<ty::FloatVid>,
+ float_unification_storage: ut::UnificationTableStorage<ty::FloatVid>,
/// Tracks the set of region variables and the constraints between them.
/// This is initially `Some(_)` but when
fn new() -> InferCtxtInner<'tcx> {
InferCtxtInner {
projection_cache: Default::default(),
- type_variables: type_variable::TypeVariableStorage::new(),
+ type_variable_storage: type_variable::TypeVariableStorage::new(),
undo_log: InferCtxtUndoLogs::default(),
- const_unification_table: ut::UnificationTableStorage::new(),
- int_unification_table: ut::UnificationTableStorage::new(),
- float_unification_table: ut::UnificationTableStorage::new(),
+ const_unification_storage: ut::UnificationTableStorage::new(),
+ int_unification_storage: ut::UnificationTableStorage::new(),
+ float_unification_storage: ut::UnificationTableStorage::new(),
region_constraints: Some(RegionConstraintStorage::new()),
region_obligations: vec![],
}
&self.region_obligations
}
- pub(crate) fn projection_cache(&mut self) -> traits::ProjectionCache<'tcx, '_> {
+ pub fn projection_cache(&mut self) -> traits::ProjectionCache<'_, 'tcx> {
self.projection_cache.with_log(&mut self.undo_log)
}
- fn type_variables(&mut self) -> type_variable::TypeVariableTable<'tcx, '_> {
- self.type_variables.with_log(&mut self.undo_log)
+ fn type_variables(&mut self) -> type_variable::TypeVariableTable<'_, 'tcx> {
+ self.type_variable_storage.with_log(&mut self.undo_log)
}
fn int_unification_table(
&mut InferCtxtUndoLogs<'tcx>,
>,
> {
- self.int_unification_table.with_log(&mut self.undo_log)
+ self.int_unification_storage.with_log(&mut self.undo_log)
}
fn float_unification_table(
&mut InferCtxtUndoLogs<'tcx>,
>,
> {
- self.float_unification_table.with_log(&mut self.undo_log)
+ self.float_unification_storage.with_log(&mut self.undo_log)
}
fn const_unification_table(
&mut InferCtxtUndoLogs<'tcx>,
>,
> {
- self.const_unification_table.with_log(&mut self.undo_log)
+ self.const_unification_storage.with_log(&mut self.undo_log)
}
pub fn unwrap_region_constraints(&mut self) -> RegionConstraintCollector<'tcx, '_> {
self.in_snapshot.set(was_in_snapshot);
self.universe.set(universe);
- let InferCtxtInner {
- type_variables,
- const_unification_table,
- int_unification_table,
- float_unification_table,
- region_constraints,
- projection_cache,
- region_obligations,
- undo_log,
- ..
- } = &mut *self.inner.borrow_mut();
- undo_log.rollback_to(
- || undo_log::RollbackView {
- type_variables,
- const_unification_table,
- int_unification_table,
- float_unification_table,
- region_constraints: region_constraints.as_mut().unwrap(),
- projection_cache,
- region_obligations,
- },
- undo_snapshot,
- );
+ self.inner.borrow_mut().rollback_to(undo_snapshot);
}
fn commit_from(&self, snapshot: CombinedSnapshot<'a, 'tcx>) {
self.in_snapshot.set(was_in_snapshot);
- let mut inner = self.inner.borrow_mut();
- inner.undo_log.commit(undo_snapshot);
+ self.inner.borrow_mut().commit(undo_snapshot);
}
/// Executes `f` and commit the bindings.
outlives_env: &OutlivesEnvironment<'tcx>,
mode: RegionckMode,
) {
- assert!(
- self.is_tainted_by_errors() || self.inner.borrow().region_obligations.is_empty(),
- "region_obligations not empty: {:#?}",
- self.inner.borrow().region_obligations
- );
- let (var_infos, data) = self
- .inner
- .borrow_mut()
- .region_constraints
- .take()
- .expect("regions already resolved")
- .with_log(&mut inner.undo_log)
- .into_infos_and_data();
+ let (var_infos, data) = {
+ let mut inner = self.inner.borrow_mut();
+ let inner = &mut *inner;
+ assert!(
+ self.is_tainted_by_errors() || inner.region_obligations.is_empty(),
+ "region_obligations not empty: {:#?}",
+ inner.region_obligations
+ );
+ inner
+ .region_constraints
+ .take()
+ .expect("regions already resolved")
+ .with_log(&mut inner.undo_log)
+ .into_infos_and_data()
+ };
let region_rels = &RegionRelations::new(
self.tcx,
/// having to resort to storing full `GenericArg`s in `stalled_on`.
#[inline(always)]
pub fn ty_or_const_infer_var_changed(&self, infer_var: TyOrConstInferVar<'tcx>) -> bool {
+ let mut inner = self.inner.borrow_mut();
match infer_var {
TyOrConstInferVar::Ty(v) => {
use self::type_variable::TypeVariableValue;
// If `inlined_probe` returns a `Known` value, it never equals
// `ty::Infer(ty::TyVar(v))`.
- match self.inner.borrow_mut().type_variables().inlined_probe(v) {
+ match inner.type_variables().inlined_probe(v) {
TypeVariableValue::Unknown { .. } => false,
TypeVariableValue::Known { .. } => true,
}
// If `inlined_probe_value` returns a value it's always a
// `ty::Int(_)` or `ty::UInt(_)`, which never matches a
// `ty::Infer(_)`.
- self.inner.borrow_mut().int_unification_table().inlined_probe_value(v).is_some()
+ inner.int_unification_table().inlined_probe_value(v).is_some()
}
TyOrConstInferVar::TyFloat(v) => {
// `ty::Float(_)`, which never matches a `ty::Infer(_)`.
//
// Not `inlined_probe_value(v)` because this call site is colder.
- self.inner.borrow_mut().float_unification_table().probe_value(v).is_some()
+ inner.float_unification_table().probe_value(v).is_some()
}
TyOrConstInferVar::Const(v) => {
// `ty::ConstKind::Infer(ty::InferConst::Var(v))`.
//
// Not `inlined_probe_value(v)` because this call site is colder.
- match self.inner.borrow_mut().const_unification_table.probe_value(v).val {
+ match inner.const_unification_table().probe_value(v).val {
ConstVariableValue::Unknown { .. } => false,
ConstVariableValue::Known { .. } => true,
}