refactor: simplify

This commit is contained in:
Markus Westerlind
2020-03-03 10:23:04 +01:00
parent 729d16f010
commit fba241fc66
2 changed files with 14 additions and 15 deletions
+5 -5
View File
@@ -24,9 +24,9 @@ fn vars_since_snapshot<'tcx, T>(
fn const_vars_since_snapshot<'tcx>(
table: &mut UnificationTable<'_, 'tcx, ConstVid<'tcx>>,
snapshot: usize,
snapshot_var_len: usize,
) -> (Range<ConstVid<'tcx>>, Vec<ConstVariableOrigin>) {
let range = vars_since_snapshot(table, snapshot);
let range = vars_since_snapshot(table, snapshot_var_len);
(
range.start..range.end,
(range.start.index..range.end.index)
@@ -98,18 +98,18 @@ pub fn fudge_inference_if_ok<T, E, F>(&self, f: F) -> Result<T, E>
inner.type_variables().vars_since_snapshot(&snapshot.type_snapshot);
let int_vars = vars_since_snapshot(
&mut inner.int_unification_table(),
snapshot.int_snapshot,
snapshot.int_var_len,
);
let float_vars = vars_since_snapshot(
&mut inner.float_unification_table(),
snapshot.float_snapshot,
snapshot.float_var_len,
);
let region_vars = inner
.unwrap_region_constraints()
.vars_since_snapshot(&snapshot.region_constraints_snapshot);
let const_vars = const_vars_since_snapshot(
&mut inner.const_unification_table(),
snapshot.const_snapshot,
snapshot.const_var_len,
);
let fudger = InferenceFudger {
+9 -10
View File
@@ -39,7 +39,6 @@
use std::cell::{Cell, Ref, RefCell};
use std::collections::BTreeMap;
use std::fmt;
use std::marker::PhantomData;
use self::combine::CombineFields;
use self::free_regions::RegionRelations;
@@ -241,7 +240,7 @@ fn int_unification_table(
&mut InferCtxtUndoLogs<'tcx>,
>,
> {
ut::UnificationTable::with_log(&mut self.int_unification_table, &mut self.undo_log)
self.int_unification_table.with_log(&mut self.undo_log)
}
fn float_unification_table(
@@ -253,7 +252,7 @@ fn float_unification_table(
&mut InferCtxtUndoLogs<'tcx>,
>,
> {
ut::UnificationTable::with_log(&mut self.float_unification_table, &mut self.undo_log)
self.float_unification_table.with_log(&mut self.undo_log)
}
fn const_unification_table(
@@ -265,7 +264,7 @@ fn const_unification_table(
&mut InferCtxtUndoLogs<'tcx>,
>,
> {
ut::UnificationTable::with_log(&mut self.const_unification_table, &mut self.undo_log)
self.const_unification_table.with_log(&mut self.undo_log)
}
pub fn unwrap_region_constraints(&mut self) -> RegionConstraintCollector<'tcx, '_> {
@@ -711,9 +710,9 @@ pub struct FullSnapshot<'a, 'tcx> {
snapshot: CombinedSnapshot<'a, 'tcx>,
region_constraints_snapshot: RegionSnapshot,
type_snapshot: type_variable::Snapshot<'tcx>,
const_snapshot: usize,
int_snapshot: usize,
float_snapshot: usize,
const_var_len: usize,
int_var_len: usize,
float_var_len: usize,
}
#[must_use = "once you start a snapshot, you should always consume it"]
@@ -837,9 +836,9 @@ fn start_full_snapshot(&self) -> FullSnapshot<'a, 'tcx> {
FullSnapshot {
snapshot,
type_snapshot: inner.type_variables().snapshot(),
const_snapshot: inner.const_unification_table().len(),
int_snapshot: inner.int_unification_table().len(),
float_snapshot: inner.float_unification_table().len(),
const_var_len: inner.const_unification_table().len(),
int_var_len: inner.int_unification_table().len(),
float_var_len: inner.float_unification_table().len(),
region_constraints_snapshot: inner.unwrap_region_constraints().start_snapshot(),
}
}