add method take_and_reset_region_constraints
to InferCtxt
This commit is contained in:
parent
1efcf1a115
commit
1430a600de
2 changed files with 26 additions and 1 deletions
|
@ -16,7 +16,7 @@ pub use self::SubregionOrigin::*;
|
|||
pub use self::ValuePairs::*;
|
||||
pub use ty::IntVarValue;
|
||||
pub use self::freshen::TypeFreshener;
|
||||
pub use self::region_constraints::{GenericKind, VerifyBound};
|
||||
pub use self::region_constraints::{GenericKind, VerifyBound, RegionConstraintData};
|
||||
|
||||
use hir::def_id::DefId;
|
||||
use middle::free_region::{FreeRegionMap, RegionRelations};
|
||||
|
@ -1152,6 +1152,20 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Obtains (and clears) the current set of region
|
||||
/// constraints. The inference context is still usable: further
|
||||
/// unifications will simply add new constraints.
|
||||
///
|
||||
/// This method is not meant to be used with normal lexical region
|
||||
/// resolution. Rather, it is used in the NLL mode as a kind of
|
||||
/// interim hack: basically we run normal type-check and generate
|
||||
/// region constraints as normal, but then we take them and
|
||||
/// translate them into the form that the NLL solver
|
||||
/// understands. See the NLL module for mode details.
|
||||
pub fn take_and_reset_region_constraints(&self) -> RegionConstraintData<'tcx> {
|
||||
self.borrow_region_constraints().take_and_reset_data()
|
||||
}
|
||||
|
||||
pub fn ty_to_string(&self, t: Ty<'tcx>) -> String {
|
||||
self.resolve_type_vars_if_possible(&t).to_string()
|
||||
}
|
||||
|
|
|
@ -285,10 +285,21 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
|
|||
}
|
||||
|
||||
/// Once all the constraints have been gathered, extract out the final data.
|
||||
///
|
||||
/// Not legal during a snapshot.
|
||||
pub fn into_origins_and_data(self) -> (VarOrigins, RegionConstraintData<'tcx>) {
|
||||
assert!(!self.in_snapshot());
|
||||
(self.var_origins, self.data)
|
||||
}
|
||||
|
||||
/// Takes (and clears) the current set of constraints. Note that the set of
|
||||
/// variables remains intact.
|
||||
///
|
||||
/// Not legal during a snapshot.
|
||||
pub fn take_and_reset_data(&mut self) -> RegionConstraintData<'tcx> {
|
||||
mem::replace(&mut self.data, RegionConstraintData::default())
|
||||
}
|
||||
|
||||
fn in_snapshot(&self) -> bool {
|
||||
!self.undo_log.is_empty()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue