infer: give access to region variable origins
This commit is contained in:
parent
09b44bbe77
commit
a87d1bbb93
2 changed files with 21 additions and 2 deletions
|
@ -25,7 +25,7 @@ use middle::lang_items;
|
|||
use mir::tcx::LvalueTy;
|
||||
use ty::subst::{Kind, Subst, Substs};
|
||||
use ty::{TyVid, IntVid, FloatVid};
|
||||
use ty::{self, Ty, TyCtxt};
|
||||
use ty::{self, RegionVid, Ty, TyCtxt};
|
||||
use ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric};
|
||||
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
|
||||
use ty::relate::RelateResult;
|
||||
|
@ -1166,6 +1166,21 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
self.borrow_region_constraints().take_and_reset_data()
|
||||
}
|
||||
|
||||
/// Returns the number of region variables created thus far.
|
||||
pub fn num_region_vars(&self) -> usize {
|
||||
self.borrow_region_constraints().var_origins().len()
|
||||
}
|
||||
|
||||
/// Returns an iterator over all region variables created thus far.
|
||||
pub fn all_region_vars(&self) -> impl Iterator<Item = RegionVid> {
|
||||
self.borrow_region_constraints().var_origins().indices()
|
||||
}
|
||||
|
||||
/// Returns the origin of a given region variable.
|
||||
pub fn region_var_origin(&self, var: RegionVid) -> RegionVariableOrigin {
|
||||
self.borrow_region_constraints().var_origins()[var].clone()
|
||||
}
|
||||
|
||||
pub fn ty_to_string(&self, t: Ty<'tcx>) -> String {
|
||||
self.resolve_type_vars_if_possible(&t).to_string()
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ mod taint;
|
|||
|
||||
pub struct RegionConstraintCollector<'tcx> {
|
||||
/// For each `RegionVid`, the corresponding `RegionVariableOrigin`.
|
||||
pub var_origins: IndexVec<RegionVid, RegionVariableOrigin>,
|
||||
var_origins: IndexVec<RegionVid, RegionVariableOrigin>,
|
||||
|
||||
data: RegionConstraintData<'tcx>,
|
||||
|
||||
|
@ -284,6 +284,10 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn var_origins(&self) -> &VarOrigins {
|
||||
&self.var_origins
|
||||
}
|
||||
|
||||
/// Once all the constraints have been gathered, extract out the final data.
|
||||
///
|
||||
/// Not legal during a snapshot.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue