mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-28 20:16:58 +03:00
infer: give access to region variable origins
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
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 @@ pub fn take_and_reset_region_constraints(&self) -> RegionConstraintData<'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 @@
|
||||
|
||||
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 @@ pub fn new() -> 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.
|
||||
|
||||
Reference in New Issue
Block a user