use middle::region;
use super::Constraint;
use infer::SubregionOrigin;
-use infer::region_constraints::RegionVarBindings;
+use infer::region_constraints::RegionConstraintCollector;
use util::nodemap::{FxHashMap, FxHashSet};
use std::borrow::Cow;
}
pub fn maybe_print_constraints_for<'a, 'gcx, 'tcx>(
- region_vars: &RegionVarBindings<'tcx>,
+ region_constraints: &RegionConstraintCollector<'tcx>,
region_rels: &RegionRelations<'a, 'gcx, 'tcx>)
{
let tcx = region_rels.tcx;
}
};
- match dump_region_constraints_to(region_rels, ®ion_vars.constraints, &output_path) {
+ match dump_region_constraints_to(region_rels, ®ion_constraints.constraints, &output_path) {
Ok(()) => {}
Err(e) => {
let msg = format!("io error dumping region constraints: {}", e);
use infer::RegionVariableOrigin;
use infer::region_constraints::Constraint;
use infer::region_constraints::GenericKind;
-use infer::region_constraints::RegionVarBindings;
+use infer::region_constraints::RegionConstraintCollector;
use infer::region_constraints::VerifyBound;
use middle::free_region::RegionRelations;
use rustc_data_structures::fx::FxHashSet;
type RegionGraph<'tcx> = graph::Graph<(), Constraint<'tcx>>;
-impl<'tcx> RegionVarBindings<'tcx> {
+impl<'tcx> RegionConstraintCollector<'tcx> {
/// This function performs the actual region resolution. It must be
/// called after all constraints have been added. It performs a
/// fixed-point iteration to find region values which satisfy all
LexicalRegionResolutions<'tcx>,
Vec<RegionResolutionError<'tcx>>,
) {
- debug!("RegionVarBindings: resolve_regions()");
+ debug!("RegionConstraintCollector: resolve_regions()");
let mut errors = vec![];
let values = self.infer_variable_values(region_rels, &mut errors);
(values, errors)
return (result, dup_found);
fn process_edges<'tcx>(
- this: &RegionVarBindings<'tcx>,
+ this: &RegionConstraintCollector<'tcx>,
state: &mut WalkState<'tcx>,
graph: &RegionGraph<'tcx>,
source_vid: RegionVid,
use self::combine::CombineFields;
use self::higher_ranked::HrMatchResult;
-use self::region_constraints::{RegionVarBindings, RegionSnapshot};
+use self::region_constraints::{RegionConstraintCollector, RegionSnapshot};
use self::lexical_region_resolve::LexicalRegionResolutions;
use self::type_variable::TypeVariableOrigin;
use self::unify_key::ToType;
float_unification_table: RefCell<UnificationTable<ty::FloatVid>>,
// For region variables.
- region_constraints: RefCell<RegionVarBindings<'tcx>>,
+ region_constraints: RefCell<RegionConstraintCollector<'tcx>>,
// Once region inference is done, the values for each variable.
lexical_region_resolutions: RefCell<Option<LexicalRegionResolutions<'tcx>>>,
type_variables: RefCell::new(type_variable::TypeVariableTable::new()),
int_unification_table: RefCell::new(UnificationTable::new()),
float_unification_table: RefCell::new(UnificationTable::new()),
- region_constraints: RefCell::new(RegionVarBindings::new()),
+ region_constraints: RefCell::new(RegionConstraintCollector::new()),
lexical_region_resolutions: RefCell::new(None),
selection_cache: traits::SelectionCache::new(),
evaluation_cache: traits::EvaluationCache::new(),
type CombineMap<'tcx> = FxHashMap<TwoRegions<'tcx>, RegionVid>;
-pub struct RegionVarBindings<'tcx> {
+pub struct RegionConstraintCollector<'tcx> {
pub(in infer) var_origins: Vec<RegionVariableOrigin>,
/// Constraints of the form `A <= B` introduced by the region
}
}
-impl<'tcx> RegionVarBindings<'tcx> {
- pub fn new() -> RegionVarBindings<'tcx> {
- RegionVarBindings {
+impl<'tcx> RegionConstraintCollector<'tcx> {
+ pub fn new() -> RegionConstraintCollector<'tcx> {
+ RegionConstraintCollector {
var_origins: Vec::new(),
constraints: BTreeMap::new(),
verifys: Vec::new(),
pub fn start_snapshot(&mut self) -> RegionSnapshot {
let length = self.undo_log.len();
- debug!("RegionVarBindings: start_snapshot({})", length);
+ debug!("RegionConstraintCollector: start_snapshot({})", length);
self.undo_log.push(OpenSnapshot);
RegionSnapshot {
length,
}
pub fn commit(&mut self, snapshot: RegionSnapshot) {
- debug!("RegionVarBindings: commit({})", snapshot.length);
+ debug!("RegionConstraintCollector: commit({})", snapshot.length);
assert!(self.undo_log.len() > snapshot.length);
assert!(self.undo_log[snapshot.length] == OpenSnapshot);
assert!(
}
pub fn rollback_to(&mut self, snapshot: RegionSnapshot) {
- debug!("RegionVarBindings: rollback_to({:?})", snapshot);
+ debug!("RegionConstraintCollector: rollback_to({:?})", snapshot);
assert!(self.undo_log.len() > snapshot.length);
assert!(self.undo_log[snapshot.length] == OpenSnapshot);
while self.undo_log.len() > snapshot.length + 1 {
fn add_constraint(&mut self, constraint: Constraint<'tcx>, origin: SubregionOrigin<'tcx>) {
// cannot add constraints once regions are resolved
- debug!("RegionVarBindings: add_constraint({:?})", constraint);
+ debug!("RegionConstraintCollector: add_constraint({:?})", constraint);
// never overwrite an existing (constraint, origin) - only insert one if it isn't
// present in the map yet. This prevents origins from outside the snapshot being
fn add_verify(&mut self, verify: Verify<'tcx>) {
// cannot add verifys once regions are resolved
- debug!("RegionVarBindings: add_verify({:?})", verify);
+ debug!("RegionConstraintCollector: add_verify({:?})", verify);
// skip no-op cases known to be satisfied
match verify.bound {
) {
// cannot add constraints once regions are resolved
debug!(
- "RegionVarBindings: make_subregion({:?}, {:?}) due to {:?}",
+ "RegionConstraintCollector: make_subregion({:?}, {:?}) due to {:?}",
sub,
sup,
origin
b: Region<'tcx>,
) -> Region<'tcx> {
// cannot add constraints once regions are resolved
- debug!("RegionVarBindings: lub_regions({:?}, {:?})", a, b);
+ debug!("RegionConstraintCollector: lub_regions({:?}, {:?})", a, b);
match (a, b) {
(r @ &ReStatic, _) | (_, r @ &ReStatic) => {
r // nothing lives longer than static
b: Region<'tcx>,
) -> Region<'tcx> {
// cannot add constraints once regions are resolved
- debug!("RegionVarBindings: glb_regions({:?}, {:?})", a, b);
+ debug!("RegionConstraintCollector: glb_regions({:?}, {:?})", a, b);
match (a, b) {
(&ReStatic, r) | (r, &ReStatic) => {
r // static lives longer than everything else