Rename the cryptic cres and ures types.
This commit is contained in:
parent
b3317d6891
commit
0939837867
13 changed files with 138 additions and 165 deletions
|
|
@ -29,7 +29,7 @@ use middle::ty::BuiltinBounds;
|
|||
use middle::ty::{self, Ty};
|
||||
use middle::ty::TyVar;
|
||||
use middle::infer::combine::*;
|
||||
use middle::infer::cres;
|
||||
use middle::infer::CombineResult;
|
||||
use middle::infer::type_variable::BiTo;
|
||||
use util::ppaux::Repr;
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ impl<'f, 'tcx> Combine<'tcx> for Bivariate<'f, 'tcx> {
|
|||
fn fields<'a>(&'a self) -> &'a CombineFields<'a, 'tcx> { &self.fields }
|
||||
|
||||
fn tys_with_variance(&self, v: ty::Variance, a: Ty<'tcx>, b: Ty<'tcx>)
|
||||
-> cres<'tcx, Ty<'tcx>>
|
||||
-> CombineResult<'tcx, Ty<'tcx>>
|
||||
{
|
||||
match v {
|
||||
ty::Invariant => self.equate().tys(a, b),
|
||||
|
|
@ -58,7 +58,7 @@ impl<'f, 'tcx> Combine<'tcx> for Bivariate<'f, 'tcx> {
|
|||
}
|
||||
|
||||
fn regions_with_variance(&self, v: ty::Variance, a: ty::Region, b: ty::Region)
|
||||
-> cres<'tcx, ty::Region>
|
||||
-> CombineResult<'tcx, ty::Region>
|
||||
{
|
||||
match v {
|
||||
ty::Invariant => self.equate().regions(a, b),
|
||||
|
|
@ -68,14 +68,14 @@ impl<'f, 'tcx> Combine<'tcx> for Bivariate<'f, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn regions(&self, a: ty::Region, _: ty::Region) -> cres<'tcx, ty::Region> {
|
||||
fn regions(&self, a: ty::Region, _: ty::Region) -> CombineResult<'tcx, ty::Region> {
|
||||
Ok(a)
|
||||
}
|
||||
|
||||
fn builtin_bounds(&self,
|
||||
a: BuiltinBounds,
|
||||
b: BuiltinBounds)
|
||||
-> cres<'tcx, BuiltinBounds>
|
||||
-> CombineResult<'tcx, BuiltinBounds>
|
||||
{
|
||||
if a != b {
|
||||
Err(ty::terr_builtin_bounds(expected_found(self, a, b)))
|
||||
|
|
@ -84,7 +84,7 @@ impl<'f, 'tcx> Combine<'tcx> for Bivariate<'f, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>> {
|
||||
fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> CombineResult<'tcx, Ty<'tcx>> {
|
||||
debug!("{}.tys({}, {})", self.tag(),
|
||||
a.repr(self.fields.infcx.tcx), b.repr(self.fields.infcx.tcx));
|
||||
if a == b { return Ok(a); }
|
||||
|
|
@ -114,7 +114,7 @@ impl<'f, 'tcx> Combine<'tcx> for Bivariate<'f, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn binders<T>(&self, a: &ty::Binder<T>, b: &ty::Binder<T>) -> cres<'tcx, ty::Binder<T>>
|
||||
fn binders<T>(&self, a: &ty::Binder<T>, b: &ty::Binder<T>) -> CombineResult<'tcx, ty::Binder<T>>
|
||||
where T : Combineable<'tcx>
|
||||
{
|
||||
let a1 = ty::erase_late_bound_regions(self.tcx(), a);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ use super::glb::Glb;
|
|||
use super::lub::Lub;
|
||||
use super::sub::Sub;
|
||||
use super::unify::InferCtxtMethodsForSimplyUnifiableTypes;
|
||||
use super::{InferCtxt, cres};
|
||||
use super::{InferCtxt, CombineResult};
|
||||
use super::{MiscVariable, TypeTrace};
|
||||
use super::type_variable::{RelationDir, BiTo, EqTo, SubtypeOf, SupertypeOf};
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ pub trait Combine<'tcx> : Sized {
|
|||
fn lub<'a>(&'a self) -> Lub<'a, 'tcx> { Lub(self.fields().clone()) }
|
||||
fn glb<'a>(&'a self) -> Glb<'a, 'tcx> { Glb(self.fields().clone()) }
|
||||
|
||||
fn mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>> {
|
||||
fn mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> CombineResult<'tcx, ty::mt<'tcx>> {
|
||||
debug!("{}.mts({}, {})",
|
||||
self.tag(),
|
||||
a.repr(self.tcx()),
|
||||
|
|
@ -94,20 +94,20 @@ pub trait Combine<'tcx> : Sized {
|
|||
}
|
||||
|
||||
fn tys_with_variance(&self, variance: ty::Variance, a: Ty<'tcx>, b: Ty<'tcx>)
|
||||
-> cres<'tcx, Ty<'tcx>>;
|
||||
-> CombineResult<'tcx, Ty<'tcx>>;
|
||||
|
||||
fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>>;
|
||||
fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> CombineResult<'tcx, Ty<'tcx>>;
|
||||
|
||||
fn regions_with_variance(&self, variance: ty::Variance, a: ty::Region, b: ty::Region)
|
||||
-> cres<'tcx, ty::Region>;
|
||||
-> CombineResult<'tcx, ty::Region>;
|
||||
|
||||
fn regions(&self, a: ty::Region, b: ty::Region) -> cres<'tcx, ty::Region>;
|
||||
fn regions(&self, a: ty::Region, b: ty::Region) -> CombineResult<'tcx, ty::Region>;
|
||||
|
||||
fn substs(&self,
|
||||
item_def_id: ast::DefId,
|
||||
a_subst: &subst::Substs<'tcx>,
|
||||
b_subst: &subst::Substs<'tcx>)
|
||||
-> cres<'tcx, subst::Substs<'tcx>>
|
||||
-> CombineResult<'tcx, subst::Substs<'tcx>>
|
||||
{
|
||||
debug!("substs: item_def_id={} a_subst={} b_subst={}",
|
||||
item_def_id.repr(self.infcx().tcx),
|
||||
|
|
@ -126,7 +126,7 @@ pub trait Combine<'tcx> : Sized {
|
|||
variances: Option<&ty::ItemVariances>,
|
||||
a_subst: &subst::Substs<'tcx>,
|
||||
b_subst: &subst::Substs<'tcx>)
|
||||
-> cres<'tcx, subst::Substs<'tcx>>
|
||||
-> CombineResult<'tcx, subst::Substs<'tcx>>
|
||||
{
|
||||
let mut substs = subst::Substs::empty();
|
||||
|
||||
|
|
@ -163,7 +163,7 @@ pub trait Combine<'tcx> : Sized {
|
|||
variances: Option<&[ty::Variance]>,
|
||||
a_tys: &[Ty<'tcx>],
|
||||
b_tys: &[Ty<'tcx>])
|
||||
-> cres<'tcx, Vec<Ty<'tcx>>>
|
||||
-> CombineResult<'tcx, Vec<Ty<'tcx>>>
|
||||
{
|
||||
if a_tys.len() != b_tys.len() {
|
||||
return Err(ty::terr_ty_param_size(expected_found(this,
|
||||
|
|
@ -183,7 +183,7 @@ pub trait Combine<'tcx> : Sized {
|
|||
variances: Option<&[ty::Variance]>,
|
||||
a_rs: &[ty::Region],
|
||||
b_rs: &[ty::Region])
|
||||
-> cres<'tcx, Vec<ty::Region>>
|
||||
-> CombineResult<'tcx, Vec<ty::Region>>
|
||||
{
|
||||
let tcx = this.infcx().tcx;
|
||||
let num_region_params = a_rs.len();
|
||||
|
|
@ -212,7 +212,7 @@ pub trait Combine<'tcx> : Sized {
|
|||
}
|
||||
|
||||
fn bare_fn_tys(&self, a: &ty::BareFnTy<'tcx>,
|
||||
b: &ty::BareFnTy<'tcx>) -> cres<'tcx, ty::BareFnTy<'tcx>> {
|
||||
b: &ty::BareFnTy<'tcx>) -> CombineResult<'tcx, ty::BareFnTy<'tcx>> {
|
||||
let unsafety = try!(self.unsafeties(a.unsafety, b.unsafety));
|
||||
let abi = try!(self.abi(a.abi, b.abi));
|
||||
let sig = try!(self.binders(&a.sig, &b.sig));
|
||||
|
|
@ -221,7 +221,7 @@ pub trait Combine<'tcx> : Sized {
|
|||
sig: sig})
|
||||
}
|
||||
|
||||
fn fn_sigs(&self, a: &ty::FnSig<'tcx>, b: &ty::FnSig<'tcx>) -> cres<'tcx, ty::FnSig<'tcx>> {
|
||||
fn fn_sigs(&self, a: &ty::FnSig<'tcx>, b: &ty::FnSig<'tcx>) -> CombineResult<'tcx, ty::FnSig<'tcx>> {
|
||||
if a.variadic != b.variadic {
|
||||
return Err(ty::terr_variadic_mismatch(expected_found(self, a.variadic, b.variadic)));
|
||||
}
|
||||
|
|
@ -248,7 +248,7 @@ pub trait Combine<'tcx> : Sized {
|
|||
fn argvecs<'tcx, C>(combiner: &C,
|
||||
a_args: &[Ty<'tcx>],
|
||||
b_args: &[Ty<'tcx>])
|
||||
-> cres<'tcx, Vec<Ty<'tcx>>>
|
||||
-> CombineResult<'tcx, Vec<Ty<'tcx>>>
|
||||
where C: Combine<'tcx> {
|
||||
if a_args.len() == b_args.len() {
|
||||
a_args.iter().zip(b_args.iter())
|
||||
|
|
@ -259,11 +259,11 @@ pub trait Combine<'tcx> : Sized {
|
|||
}
|
||||
}
|
||||
|
||||
fn args(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>> {
|
||||
fn args(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> CombineResult<'tcx, Ty<'tcx>> {
|
||||
self.tys_with_variance(ty::Contravariant, a, b).and_then(|t| Ok(t))
|
||||
}
|
||||
|
||||
fn unsafeties(&self, a: Unsafety, b: Unsafety) -> cres<'tcx, Unsafety> {
|
||||
fn unsafeties(&self, a: Unsafety, b: Unsafety) -> CombineResult<'tcx, Unsafety> {
|
||||
if a != b {
|
||||
Err(ty::terr_unsafety_mismatch(expected_found(self, a, b)))
|
||||
} else {
|
||||
|
|
@ -271,7 +271,7 @@ pub trait Combine<'tcx> : Sized {
|
|||
}
|
||||
}
|
||||
|
||||
fn abi(&self, a: abi::Abi, b: abi::Abi) -> cres<'tcx, abi::Abi> {
|
||||
fn abi(&self, a: abi::Abi, b: abi::Abi) -> CombineResult<'tcx, abi::Abi> {
|
||||
if a == b {
|
||||
Ok(a)
|
||||
} else {
|
||||
|
|
@ -282,7 +282,7 @@ pub trait Combine<'tcx> : Sized {
|
|||
fn projection_tys(&self,
|
||||
a: &ty::ProjectionTy<'tcx>,
|
||||
b: &ty::ProjectionTy<'tcx>)
|
||||
-> cres<'tcx, ty::ProjectionTy<'tcx>>
|
||||
-> CombineResult<'tcx, ty::ProjectionTy<'tcx>>
|
||||
{
|
||||
if a.item_name != b.item_name {
|
||||
Err(ty::terr_projection_name_mismatched(
|
||||
|
|
@ -296,7 +296,7 @@ pub trait Combine<'tcx> : Sized {
|
|||
fn projection_predicates(&self,
|
||||
a: &ty::ProjectionPredicate<'tcx>,
|
||||
b: &ty::ProjectionPredicate<'tcx>)
|
||||
-> cres<'tcx, ty::ProjectionPredicate<'tcx>>
|
||||
-> CombineResult<'tcx, ty::ProjectionPredicate<'tcx>>
|
||||
{
|
||||
let projection_ty = try!(self.projection_tys(&a.projection_ty, &b.projection_ty));
|
||||
let ty = try!(self.tys(a.ty, b.ty));
|
||||
|
|
@ -306,7 +306,7 @@ pub trait Combine<'tcx> : Sized {
|
|||
fn projection_bounds(&self,
|
||||
a: &Vec<ty::PolyProjectionPredicate<'tcx>>,
|
||||
b: &Vec<ty::PolyProjectionPredicate<'tcx>>)
|
||||
-> cres<'tcx, Vec<ty::PolyProjectionPredicate<'tcx>>>
|
||||
-> CombineResult<'tcx, Vec<ty::PolyProjectionPredicate<'tcx>>>
|
||||
{
|
||||
// To be compatible, `a` and `b` must be for precisely the
|
||||
// same set of traits and item names. We always require that
|
||||
|
|
@ -326,7 +326,7 @@ pub trait Combine<'tcx> : Sized {
|
|||
fn existential_bounds(&self,
|
||||
a: &ty::ExistentialBounds<'tcx>,
|
||||
b: &ty::ExistentialBounds<'tcx>)
|
||||
-> cres<'tcx, ty::ExistentialBounds<'tcx>>
|
||||
-> CombineResult<'tcx, ty::ExistentialBounds<'tcx>>
|
||||
{
|
||||
let r = try!(self.regions_with_variance(ty::Contravariant, a.region_bound, b.region_bound));
|
||||
let nb = try!(self.builtin_bounds(a.builtin_bounds, b.builtin_bounds));
|
||||
|
|
@ -339,7 +339,7 @@ pub trait Combine<'tcx> : Sized {
|
|||
fn builtin_bounds(&self,
|
||||
a: BuiltinBounds,
|
||||
b: BuiltinBounds)
|
||||
-> cres<'tcx, BuiltinBounds>
|
||||
-> CombineResult<'tcx, BuiltinBounds>
|
||||
{
|
||||
// Two sets of builtin bounds are only relatable if they are
|
||||
// precisely the same (but see the coercion code).
|
||||
|
|
@ -353,7 +353,7 @@ pub trait Combine<'tcx> : Sized {
|
|||
fn trait_refs(&self,
|
||||
a: &ty::TraitRef<'tcx>,
|
||||
b: &ty::TraitRef<'tcx>)
|
||||
-> cres<'tcx, ty::TraitRef<'tcx>>
|
||||
-> CombineResult<'tcx, ty::TraitRef<'tcx>>
|
||||
{
|
||||
// Different traits cannot be related
|
||||
if a.def_id != b.def_id {
|
||||
|
|
@ -364,14 +364,14 @@ pub trait Combine<'tcx> : Sized {
|
|||
}
|
||||
}
|
||||
|
||||
fn binders<T>(&self, a: &ty::Binder<T>, b: &ty::Binder<T>) -> cres<'tcx, ty::Binder<T>>
|
||||
fn binders<T>(&self, a: &ty::Binder<T>, b: &ty::Binder<T>) -> CombineResult<'tcx, ty::Binder<T>>
|
||||
where T : Combineable<'tcx>;
|
||||
// this must be overridden to do correctly, so as to account for higher-ranked
|
||||
// behavior
|
||||
}
|
||||
|
||||
pub trait Combineable<'tcx> : Repr<'tcx> + TypeFoldable<'tcx> {
|
||||
fn combine<C:Combine<'tcx>>(combiner: &C, a: &Self, b: &Self) -> cres<'tcx, Self>;
|
||||
fn combine<C:Combine<'tcx>>(combiner: &C, a: &Self, b: &Self) -> CombineResult<'tcx, Self>;
|
||||
}
|
||||
|
||||
impl<'tcx,T> Combineable<'tcx> for Rc<T>
|
||||
|
|
@ -380,7 +380,7 @@ impl<'tcx,T> Combineable<'tcx> for Rc<T>
|
|||
fn combine<C>(combiner: &C,
|
||||
a: &Rc<T>,
|
||||
b: &Rc<T>)
|
||||
-> cres<'tcx, Rc<T>>
|
||||
-> CombineResult<'tcx, Rc<T>>
|
||||
where C: Combine<'tcx> {
|
||||
Ok(Rc::new(try!(Combineable::combine(combiner, &**a, &**b))))
|
||||
}
|
||||
|
|
@ -390,7 +390,7 @@ impl<'tcx> Combineable<'tcx> for ty::TraitRef<'tcx> {
|
|||
fn combine<C>(combiner: &C,
|
||||
a: &ty::TraitRef<'tcx>,
|
||||
b: &ty::TraitRef<'tcx>)
|
||||
-> cres<'tcx, ty::TraitRef<'tcx>>
|
||||
-> CombineResult<'tcx, ty::TraitRef<'tcx>>
|
||||
where C: Combine<'tcx> {
|
||||
combiner.trait_refs(a, b)
|
||||
}
|
||||
|
|
@ -400,7 +400,7 @@ impl<'tcx> Combineable<'tcx> for Ty<'tcx> {
|
|||
fn combine<C>(combiner: &C,
|
||||
a: &Ty<'tcx>,
|
||||
b: &Ty<'tcx>)
|
||||
-> cres<'tcx, Ty<'tcx>>
|
||||
-> CombineResult<'tcx, Ty<'tcx>>
|
||||
where C: Combine<'tcx> {
|
||||
combiner.tys(*a, *b)
|
||||
}
|
||||
|
|
@ -410,7 +410,7 @@ impl<'tcx> Combineable<'tcx> for ty::ProjectionPredicate<'tcx> {
|
|||
fn combine<C>(combiner: &C,
|
||||
a: &ty::ProjectionPredicate<'tcx>,
|
||||
b: &ty::ProjectionPredicate<'tcx>)
|
||||
-> cres<'tcx, ty::ProjectionPredicate<'tcx>>
|
||||
-> CombineResult<'tcx, ty::ProjectionPredicate<'tcx>>
|
||||
where C: Combine<'tcx> {
|
||||
combiner.projection_predicates(a, b)
|
||||
}
|
||||
|
|
@ -420,7 +420,7 @@ impl<'tcx> Combineable<'tcx> for ty::FnSig<'tcx> {
|
|||
fn combine<C>(combiner: &C,
|
||||
a: &ty::FnSig<'tcx>,
|
||||
b: &ty::FnSig<'tcx>)
|
||||
-> cres<'tcx, ty::FnSig<'tcx>>
|
||||
-> CombineResult<'tcx, ty::FnSig<'tcx>>
|
||||
where C: Combine<'tcx> {
|
||||
combiner.fn_sigs(a, b)
|
||||
}
|
||||
|
|
@ -448,7 +448,7 @@ pub fn expected_found<'tcx, C, T>(this: &C,
|
|||
pub fn super_tys<'tcx, C>(this: &C,
|
||||
a: Ty<'tcx>,
|
||||
b: Ty<'tcx>)
|
||||
-> cres<'tcx, Ty<'tcx>>
|
||||
-> CombineResult<'tcx, Ty<'tcx>>
|
||||
where C: Combine<'tcx> {
|
||||
let tcx = this.infcx().tcx;
|
||||
let a_sty = &a.sty;
|
||||
|
|
@ -616,7 +616,7 @@ pub fn super_tys<'tcx, C>(this: &C,
|
|||
vid_is_expected: bool,
|
||||
vid: ty::IntVid,
|
||||
val: ty::IntVarValue)
|
||||
-> cres<'tcx, Ty<'tcx>>
|
||||
-> CombineResult<'tcx, Ty<'tcx>>
|
||||
where C: Combine<'tcx> {
|
||||
try!(this.infcx().simple_var_t(vid_is_expected, vid, val));
|
||||
match val {
|
||||
|
|
@ -629,7 +629,7 @@ pub fn super_tys<'tcx, C>(this: &C,
|
|||
vid_is_expected: bool,
|
||||
vid: ty::FloatVid,
|
||||
val: ast::FloatTy)
|
||||
-> cres<'tcx, Ty<'tcx>>
|
||||
-> CombineResult<'tcx, Ty<'tcx>>
|
||||
where C: Combine<'tcx> {
|
||||
try!(this.infcx().simple_var_t(vid_is_expected, vid, val));
|
||||
Ok(ty::mk_mach_float(this.tcx(), val))
|
||||
|
|
@ -660,7 +660,7 @@ impl<'f, 'tcx> CombineFields<'f, 'tcx> {
|
|||
a_ty: Ty<'tcx>,
|
||||
dir: RelationDir,
|
||||
b_vid: ty::TyVid)
|
||||
-> cres<'tcx, ()>
|
||||
-> CombineResult<'tcx, ()>
|
||||
{
|
||||
let tcx = self.infcx.tcx;
|
||||
let mut stack = Vec::new();
|
||||
|
|
@ -746,7 +746,7 @@ impl<'f, 'tcx> CombineFields<'f, 'tcx> {
|
|||
ty: Ty<'tcx>,
|
||||
for_vid: ty::TyVid,
|
||||
make_region_vars: bool)
|
||||
-> cres<'tcx, Ty<'tcx>>
|
||||
-> CombineResult<'tcx, Ty<'tcx>>
|
||||
{
|
||||
let mut generalize = Generalizer {
|
||||
infcx: self.infcx,
|
||||
|
|
@ -839,3 +839,23 @@ impl<'cx, 'tcx> ty_fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> {
|
|||
self.infcx.next_region_var(MiscVariable(self.span))
|
||||
}
|
||||
}
|
||||
|
||||
pub trait CombineResultCompare<'tcx, T> {
|
||||
fn compare<F>(&self, t: T, f: F) -> CombineResult<'tcx, T> where
|
||||
F: FnOnce() -> ty::type_err<'tcx>;
|
||||
}
|
||||
|
||||
impl<'tcx, T:Clone + PartialEq> CombineResultCompare<'tcx, T> for CombineResult<'tcx, T> {
|
||||
fn compare<F>(&self, t: T, f: F) -> CombineResult<'tcx, T> where
|
||||
F: FnOnce() -> ty::type_err<'tcx>,
|
||||
{
|
||||
(*self).clone().and_then(|s| {
|
||||
if s == t {
|
||||
(*self).clone()
|
||||
} else {
|
||||
Err(f())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
use middle::ty::{self, Ty};
|
||||
use middle::ty::TyVar;
|
||||
use middle::infer::combine::*;
|
||||
use middle::infer::cres;
|
||||
use middle::infer::CombineResult;
|
||||
use middle::infer::Subtype;
|
||||
use middle::infer::type_variable::EqTo;
|
||||
use util::ppaux::Repr;
|
||||
|
|
@ -30,20 +30,20 @@ impl<'f, 'tcx> Combine<'tcx> for Equate<'f, 'tcx> {
|
|||
fn fields<'a>(&'a self) -> &'a CombineFields<'a, 'tcx> { &self.fields }
|
||||
|
||||
fn tys_with_variance(&self, _: ty::Variance, a: Ty<'tcx>, b: Ty<'tcx>)
|
||||
-> cres<'tcx, Ty<'tcx>>
|
||||
-> CombineResult<'tcx, Ty<'tcx>>
|
||||
{
|
||||
// Once we're equating, it doesn't matter what the variance is.
|
||||
self.tys(a, b)
|
||||
}
|
||||
|
||||
fn regions_with_variance(&self, _: ty::Variance, a: ty::Region, b: ty::Region)
|
||||
-> cres<'tcx, ty::Region>
|
||||
-> CombineResult<'tcx, ty::Region>
|
||||
{
|
||||
// Once we're equating, it doesn't matter what the variance is.
|
||||
self.regions(a, b)
|
||||
}
|
||||
|
||||
fn regions(&self, a: ty::Region, b: ty::Region) -> cres<'tcx, ty::Region> {
|
||||
fn regions(&self, a: ty::Region, b: ty::Region) -> CombineResult<'tcx, ty::Region> {
|
||||
debug!("{}.regions({}, {})",
|
||||
self.tag(),
|
||||
a.repr(self.fields.infcx.tcx),
|
||||
|
|
@ -52,7 +52,7 @@ impl<'f, 'tcx> Combine<'tcx> for Equate<'f, 'tcx> {
|
|||
Ok(a)
|
||||
}
|
||||
|
||||
fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>> {
|
||||
fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> CombineResult<'tcx, Ty<'tcx>> {
|
||||
debug!("{}.tys({}, {})", self.tag(),
|
||||
a.repr(self.fields.infcx.tcx), b.repr(self.fields.infcx.tcx));
|
||||
if a == b { return Ok(a); }
|
||||
|
|
@ -82,7 +82,7 @@ impl<'f, 'tcx> Combine<'tcx> for Equate<'f, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn binders<T>(&self, a: &ty::Binder<T>, b: &ty::Binder<T>) -> cres<'tcx, ty::Binder<T>>
|
||||
fn binders<T>(&self, a: &ty::Binder<T>, b: &ty::Binder<T>) -> CombineResult<'tcx, ty::Binder<T>>
|
||||
where T : Combineable<'tcx>
|
||||
{
|
||||
try!(self.sub().binders(a, b));
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
use super::combine::*;
|
||||
use super::lattice::*;
|
||||
use super::higher_ranked::HigherRankedRelations;
|
||||
use super::cres;
|
||||
use super::CombineResult;
|
||||
use super::Subtype;
|
||||
|
||||
use middle::ty::{self, Ty};
|
||||
|
|
@ -32,7 +32,7 @@ impl<'f, 'tcx> Combine<'tcx> for Glb<'f, 'tcx> {
|
|||
fn fields<'a>(&'a self) -> &'a CombineFields<'a, 'tcx> { &self.fields }
|
||||
|
||||
fn tys_with_variance(&self, v: ty::Variance, a: Ty<'tcx>, b: Ty<'tcx>)
|
||||
-> cres<'tcx, Ty<'tcx>>
|
||||
-> CombineResult<'tcx, Ty<'tcx>>
|
||||
{
|
||||
match v {
|
||||
ty::Invariant => self.equate().tys(a, b),
|
||||
|
|
@ -43,7 +43,7 @@ impl<'f, 'tcx> Combine<'tcx> for Glb<'f, 'tcx> {
|
|||
}
|
||||
|
||||
fn regions_with_variance(&self, v: ty::Variance, a: ty::Region, b: ty::Region)
|
||||
-> cres<'tcx, ty::Region>
|
||||
-> CombineResult<'tcx, ty::Region>
|
||||
{
|
||||
match v {
|
||||
ty::Invariant => self.equate().regions(a, b),
|
||||
|
|
@ -53,7 +53,7 @@ impl<'f, 'tcx> Combine<'tcx> for Glb<'f, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn regions(&self, a: ty::Region, b: ty::Region) -> cres<'tcx, ty::Region> {
|
||||
fn regions(&self, a: ty::Region, b: ty::Region) -> CombineResult<'tcx, ty::Region> {
|
||||
debug!("{}.regions({}, {})",
|
||||
self.tag(),
|
||||
a.repr(self.fields.infcx.tcx),
|
||||
|
|
@ -62,11 +62,11 @@ impl<'f, 'tcx> Combine<'tcx> for Glb<'f, 'tcx> {
|
|||
Ok(self.fields.infcx.region_vars.glb_regions(Subtype(self.trace()), a, b))
|
||||
}
|
||||
|
||||
fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>> {
|
||||
fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> CombineResult<'tcx, Ty<'tcx>> {
|
||||
super_lattice_tys(self, a, b)
|
||||
}
|
||||
|
||||
fn binders<T>(&self, a: &ty::Binder<T>, b: &ty::Binder<T>) -> cres<'tcx, ty::Binder<T>>
|
||||
fn binders<T>(&self, a: &ty::Binder<T>, b: &ty::Binder<T>) -> CombineResult<'tcx, ty::Binder<T>>
|
||||
where T : Combineable<'tcx>
|
||||
{
|
||||
self.higher_ranked_glb(a, b)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
//! Helper routines for higher-ranked things. See the `doc` module at
|
||||
//! the end of the file for details.
|
||||
|
||||
use super::{CombinedSnapshot, cres, InferCtxt, HigherRankedType, SkolemizationMap};
|
||||
use super::{CombinedSnapshot, CombineResult, InferCtxt, HigherRankedType, SkolemizationMap};
|
||||
use super::combine::{Combine, Combineable};
|
||||
|
||||
use middle::subst;
|
||||
|
|
@ -22,13 +22,13 @@ use util::nodemap::{FnvHashMap, FnvHashSet};
|
|||
use util::ppaux::Repr;
|
||||
|
||||
pub trait HigherRankedRelations<'tcx> {
|
||||
fn higher_ranked_sub<T>(&self, a: &Binder<T>, b: &Binder<T>) -> cres<'tcx, Binder<T>>
|
||||
fn higher_ranked_sub<T>(&self, a: &Binder<T>, b: &Binder<T>) -> CombineResult<'tcx, Binder<T>>
|
||||
where T : Combineable<'tcx>;
|
||||
|
||||
fn higher_ranked_lub<T>(&self, a: &Binder<T>, b: &Binder<T>) -> cres<'tcx, Binder<T>>
|
||||
fn higher_ranked_lub<T>(&self, a: &Binder<T>, b: &Binder<T>) -> CombineResult<'tcx, Binder<T>>
|
||||
where T : Combineable<'tcx>;
|
||||
|
||||
fn higher_ranked_glb<T>(&self, a: &Binder<T>, b: &Binder<T>) -> cres<'tcx, Binder<T>>
|
||||
fn higher_ranked_glb<T>(&self, a: &Binder<T>, b: &Binder<T>) -> CombineResult<'tcx, Binder<T>>
|
||||
where T : Combineable<'tcx>;
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ impl<'tcx,C> HigherRankedRelations<'tcx> for C
|
|||
where C : Combine<'tcx>
|
||||
{
|
||||
fn higher_ranked_sub<T>(&self, a: &Binder<T>, b: &Binder<T>)
|
||||
-> cres<'tcx, Binder<T>>
|
||||
-> CombineResult<'tcx, Binder<T>>
|
||||
where T : Combineable<'tcx>
|
||||
{
|
||||
debug!("higher_ranked_sub(a={}, b={})",
|
||||
|
|
@ -104,7 +104,7 @@ impl<'tcx,C> HigherRankedRelations<'tcx> for C
|
|||
});
|
||||
}
|
||||
|
||||
fn higher_ranked_lub<T>(&self, a: &Binder<T>, b: &Binder<T>) -> cres<'tcx, Binder<T>>
|
||||
fn higher_ranked_lub<T>(&self, a: &Binder<T>, b: &Binder<T>) -> CombineResult<'tcx, Binder<T>>
|
||||
where T : Combineable<'tcx>
|
||||
{
|
||||
// Start a snapshot so we can examine "all bindings that were
|
||||
|
|
@ -194,7 +194,7 @@ impl<'tcx,C> HigherRankedRelations<'tcx> for C
|
|||
}
|
||||
}
|
||||
|
||||
fn higher_ranked_glb<T>(&self, a: &Binder<T>, b: &Binder<T>) -> cres<'tcx, Binder<T>>
|
||||
fn higher_ranked_glb<T>(&self, a: &Binder<T>, b: &Binder<T>) -> CombineResult<'tcx, Binder<T>>
|
||||
where T : Combineable<'tcx>
|
||||
{
|
||||
debug!("{}.higher_ranked_glb({}, {})",
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@ use util::ppaux::Repr;
|
|||
pub trait LatticeDir<'tcx> {
|
||||
// Relates the type `v` to `a` and `b` such that `v` represents
|
||||
// the LUB/GLB of `a` and `b` as appropriate.
|
||||
fn relate_bound(&self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, ()>;
|
||||
fn relate_bound(&self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> CombineResult<'tcx, ()>;
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> LatticeDir<'tcx> for Lub<'a, 'tcx> {
|
||||
fn relate_bound(&self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, ()> {
|
||||
fn relate_bound(&self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> CombineResult<'tcx, ()> {
|
||||
let sub = self.sub();
|
||||
try!(sub.tys(a, v));
|
||||
try!(sub.tys(b, v));
|
||||
|
|
@ -54,7 +54,7 @@ impl<'a, 'tcx> LatticeDir<'tcx> for Lub<'a, 'tcx> {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> LatticeDir<'tcx> for Glb<'a, 'tcx> {
|
||||
fn relate_bound(&self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, ()> {
|
||||
fn relate_bound(&self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> CombineResult<'tcx, ()> {
|
||||
let sub = self.sub();
|
||||
try!(sub.tys(v, a));
|
||||
try!(sub.tys(v, b));
|
||||
|
|
@ -65,7 +65,7 @@ impl<'a, 'tcx> LatticeDir<'tcx> for Glb<'a, 'tcx> {
|
|||
pub fn super_lattice_tys<'tcx, L:LatticeDir<'tcx>+Combine<'tcx>>(this: &L,
|
||||
a: Ty<'tcx>,
|
||||
b: Ty<'tcx>)
|
||||
-> cres<'tcx, Ty<'tcx>>
|
||||
-> CombineResult<'tcx, Ty<'tcx>>
|
||||
{
|
||||
debug!("{}.lattice_tys({}, {})",
|
||||
this.tag(),
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
use super::combine::*;
|
||||
use super::higher_ranked::HigherRankedRelations;
|
||||
use super::lattice::*;
|
||||
use super::cres;
|
||||
use super::CombineResult;
|
||||
use super::Subtype;
|
||||
|
||||
use middle::ty::{self, Ty};
|
||||
|
|
@ -32,7 +32,7 @@ impl<'f, 'tcx> Combine<'tcx> for Lub<'f, 'tcx> {
|
|||
fn fields<'a>(&'a self) -> &'a CombineFields<'a, 'tcx> { &self.fields }
|
||||
|
||||
fn tys_with_variance(&self, v: ty::Variance, a: Ty<'tcx>, b: Ty<'tcx>)
|
||||
-> cres<'tcx, Ty<'tcx>>
|
||||
-> CombineResult<'tcx, Ty<'tcx>>
|
||||
{
|
||||
match v {
|
||||
ty::Invariant => self.equate().tys(a, b),
|
||||
|
|
@ -43,7 +43,7 @@ impl<'f, 'tcx> Combine<'tcx> for Lub<'f, 'tcx> {
|
|||
}
|
||||
|
||||
fn regions_with_variance(&self, v: ty::Variance, a: ty::Region, b: ty::Region)
|
||||
-> cres<'tcx, ty::Region>
|
||||
-> CombineResult<'tcx, ty::Region>
|
||||
{
|
||||
match v {
|
||||
ty::Invariant => self.equate().regions(a, b),
|
||||
|
|
@ -53,7 +53,7 @@ impl<'f, 'tcx> Combine<'tcx> for Lub<'f, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn regions(&self, a: ty::Region, b: ty::Region) -> cres<'tcx, ty::Region> {
|
||||
fn regions(&self, a: ty::Region, b: ty::Region) -> CombineResult<'tcx, ty::Region> {
|
||||
debug!("{}.regions({}, {})",
|
||||
self.tag(),
|
||||
a.repr(self.tcx()),
|
||||
|
|
@ -62,11 +62,11 @@ impl<'f, 'tcx> Combine<'tcx> for Lub<'f, 'tcx> {
|
|||
Ok(self.infcx().region_vars.lub_regions(Subtype(self.trace()), a, b))
|
||||
}
|
||||
|
||||
fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>> {
|
||||
fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> CombineResult<'tcx, Ty<'tcx>> {
|
||||
super_lattice_tys(self, a, b)
|
||||
}
|
||||
|
||||
fn binders<T>(&self, a: &ty::Binder<T>, b: &ty::Binder<T>) -> cres<'tcx, ty::Binder<T>>
|
||||
fn binders<T>(&self, a: &ty::Binder<T>, b: &ty::Binder<T>) -> CombineResult<'tcx, ty::Binder<T>>
|
||||
where T : Combineable<'tcx>
|
||||
{
|
||||
self.higher_ranked_lub(a, b)
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ pub mod unify;
|
|||
|
||||
pub type Bound<T> = Option<T>;
|
||||
|
||||
pub type cres<'tcx, T> = Result<T,ty::type_err<'tcx>>; // "combine result"
|
||||
pub type ures<'tcx> = cres<'tcx, ()>; // "unify result"
|
||||
pub type CombineResult<'tcx, T> = Result<T,ty::type_err<'tcx>>; // "combine result"
|
||||
pub type UnitResult<'tcx> = CombineResult<'tcx, ()>; // "unify result"
|
||||
pub type fres<T> = Result<T, fixup_err>; // "fixup result"
|
||||
|
||||
pub struct InferCtxt<'a, 'tcx: 'a> {
|
||||
|
|
@ -359,7 +359,7 @@ pub fn mk_subty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
|
|||
origin: TypeOrigin,
|
||||
a: Ty<'tcx>,
|
||||
b: Ty<'tcx>)
|
||||
-> ures<'tcx>
|
||||
-> UnitResult<'tcx>
|
||||
{
|
||||
debug!("mk_subty({} <: {})", a.repr(cx.tcx), b.repr(cx.tcx));
|
||||
cx.commit_if_ok(|| {
|
||||
|
|
@ -370,18 +370,18 @@ pub fn mk_subty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
|
|||
pub fn can_mk_subty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
|
||||
a: Ty<'tcx>,
|
||||
b: Ty<'tcx>)
|
||||
-> ures<'tcx> {
|
||||
-> UnitResult<'tcx> {
|
||||
debug!("can_mk_subty({} <: {})", a.repr(cx.tcx), b.repr(cx.tcx));
|
||||
cx.probe(|_| {
|
||||
let trace = TypeTrace {
|
||||
origin: Misc(codemap::DUMMY_SP),
|
||||
values: Types(expected_found(true, a, b))
|
||||
};
|
||||
cx.sub(true, trace).tys(a, b).to_ures()
|
||||
cx.sub(true, trace).tys(a, b).map(|_| ())
|
||||
})
|
||||
}
|
||||
|
||||
pub fn can_mk_eqty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> ures<'tcx>
|
||||
pub fn can_mk_eqty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> UnitResult<'tcx>
|
||||
{
|
||||
cx.can_equate(&a, &b)
|
||||
}
|
||||
|
|
@ -401,7 +401,7 @@ pub fn mk_eqty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
|
|||
origin: TypeOrigin,
|
||||
a: Ty<'tcx>,
|
||||
b: Ty<'tcx>)
|
||||
-> ures<'tcx>
|
||||
-> UnitResult<'tcx>
|
||||
{
|
||||
debug!("mk_eqty({} <: {})", a.repr(cx.tcx), b.repr(cx.tcx));
|
||||
cx.commit_if_ok(
|
||||
|
|
@ -413,7 +413,7 @@ pub fn mk_sub_poly_trait_refs<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
|
|||
origin: TypeOrigin,
|
||||
a: ty::PolyTraitRef<'tcx>,
|
||||
b: ty::PolyTraitRef<'tcx>)
|
||||
-> ures<'tcx>
|
||||
-> UnitResult<'tcx>
|
||||
{
|
||||
debug!("mk_sub_trait_refs({} <: {})",
|
||||
a.repr(cx.tcx), b.repr(cx.tcx));
|
||||
|
|
@ -433,57 +433,6 @@ fn expected_found<T>(a_is_expected: bool,
|
|||
}
|
||||
}
|
||||
|
||||
trait then<'tcx> {
|
||||
fn then<T, F>(&self, f: F) -> Result<T, ty::type_err<'tcx>> where
|
||||
T: Clone,
|
||||
F: FnOnce() -> Result<T, ty::type_err<'tcx>>;
|
||||
}
|
||||
|
||||
impl<'tcx> then<'tcx> for ures<'tcx> {
|
||||
fn then<T, F>(&self, f: F) -> Result<T, ty::type_err<'tcx>> where
|
||||
T: Clone,
|
||||
F: FnOnce() -> Result<T, ty::type_err<'tcx>>,
|
||||
{
|
||||
self.and_then(move |_| f())
|
||||
}
|
||||
}
|
||||
|
||||
trait ToUres<'tcx> {
|
||||
fn to_ures(&self) -> ures<'tcx>;
|
||||
}
|
||||
|
||||
impl<'tcx, T> ToUres<'tcx> for cres<'tcx, T> {
|
||||
fn to_ures(&self) -> ures<'tcx> {
|
||||
match *self {
|
||||
Ok(ref _v) => Ok(()),
|
||||
Err(ref e) => Err((*e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trait CresCompare<'tcx, T> {
|
||||
fn compare<F>(&self, t: T, f: F) -> cres<'tcx, T> where
|
||||
F: FnOnce() -> ty::type_err<'tcx>;
|
||||
}
|
||||
|
||||
impl<'tcx, T:Clone + PartialEq> CresCompare<'tcx, T> for cres<'tcx, T> {
|
||||
fn compare<F>(&self, t: T, f: F) -> cres<'tcx, T> where
|
||||
F: FnOnce() -> ty::type_err<'tcx>,
|
||||
{
|
||||
(*self).clone().and_then(move |s| {
|
||||
if s == t {
|
||||
(*self).clone()
|
||||
} else {
|
||||
Err(f())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn uok<'tcx>() -> ures<'tcx> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[must_use = "once you start a snapshot, you should always consume it"]
|
||||
pub struct CombinedSnapshot {
|
||||
type_snapshot: type_variable::Snapshot,
|
||||
|
|
@ -691,12 +640,12 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
origin: TypeOrigin,
|
||||
a: Ty<'tcx>,
|
||||
b: Ty<'tcx>)
|
||||
-> ures<'tcx>
|
||||
-> UnitResult<'tcx>
|
||||
{
|
||||
debug!("sub_types({} <: {})", a.repr(self.tcx), b.repr(self.tcx));
|
||||
self.commit_if_ok(|| {
|
||||
let trace = TypeTrace::types(origin, a_is_expected, a, b);
|
||||
self.sub(a_is_expected, trace).tys(a, b).to_ures()
|
||||
self.sub(a_is_expected, trace).tys(a, b).map(|_| ())
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -705,11 +654,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
origin: TypeOrigin,
|
||||
a: Ty<'tcx>,
|
||||
b: Ty<'tcx>)
|
||||
-> ures<'tcx>
|
||||
-> UnitResult<'tcx>
|
||||
{
|
||||
self.commit_if_ok(|| {
|
||||
let trace = TypeTrace::types(origin, a_is_expected, a, b);
|
||||
self.equate(a_is_expected, trace).tys(a, b).to_ures()
|
||||
self.equate(a_is_expected, trace).tys(a, b).map(|_| ())
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -718,7 +667,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
origin: TypeOrigin,
|
||||
a: Rc<ty::TraitRef<'tcx>>,
|
||||
b: Rc<ty::TraitRef<'tcx>>)
|
||||
-> ures<'tcx>
|
||||
-> UnitResult<'tcx>
|
||||
{
|
||||
debug!("sub_trait_refs({} <: {})",
|
||||
a.repr(self.tcx),
|
||||
|
|
@ -728,7 +677,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
origin: origin,
|
||||
values: TraitRefs(expected_found(a_is_expected, a.clone(), b.clone()))
|
||||
};
|
||||
self.sub(a_is_expected, trace).trait_refs(&*a, &*b).to_ures()
|
||||
self.sub(a_is_expected, trace).trait_refs(&*a, &*b).map(|_| ())
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -737,7 +686,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
origin: TypeOrigin,
|
||||
a: ty::PolyTraitRef<'tcx>,
|
||||
b: ty::PolyTraitRef<'tcx>)
|
||||
-> ures<'tcx>
|
||||
-> UnitResult<'tcx>
|
||||
{
|
||||
debug!("sub_poly_trait_refs({} <: {})",
|
||||
a.repr(self.tcx),
|
||||
|
|
@ -747,7 +696,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
origin: origin,
|
||||
values: PolyTraitRefs(expected_found(a_is_expected, a.clone(), b.clone()))
|
||||
};
|
||||
self.sub(a_is_expected, trace).binders(&a, &b).to_ures()
|
||||
self.sub(a_is_expected, trace).binders(&a, &b).map(|_| ())
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -774,7 +723,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
pub fn leak_check(&self,
|
||||
skol_map: &SkolemizationMap,
|
||||
snapshot: &CombinedSnapshot)
|
||||
-> ures<'tcx>
|
||||
-> UnitResult<'tcx>
|
||||
{
|
||||
/*! See `higher_ranked::leak_check` */
|
||||
|
||||
|
|
@ -799,7 +748,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
pub fn equality_predicate(&self,
|
||||
span: Span,
|
||||
predicate: &ty::PolyEquatePredicate<'tcx>)
|
||||
-> ures<'tcx> {
|
||||
-> UnitResult<'tcx> {
|
||||
self.try(|snapshot| {
|
||||
let (ty::EquatePredicate(a, b), skol_map) =
|
||||
self.skolemize_late_bound_regions(predicate, snapshot);
|
||||
|
|
@ -812,7 +761,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
pub fn region_outlives_predicate(&self,
|
||||
span: Span,
|
||||
predicate: &ty::PolyRegionOutlivesPredicate)
|
||||
-> ures<'tcx> {
|
||||
-> UnitResult<'tcx> {
|
||||
self.try(|snapshot| {
|
||||
let (ty::OutlivesPredicate(r_a, r_b), skol_map) =
|
||||
self.skolemize_late_bound_regions(predicate, snapshot);
|
||||
|
|
@ -1104,7 +1053,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
self.region_vars.verify_generic_bound(origin, kind, a, bs);
|
||||
}
|
||||
|
||||
pub fn can_equate<T>(&self, a: &T, b: &T) -> ures<'tcx>
|
||||
pub fn can_equate<T>(&self, a: &T, b: &T) -> UnitResult<'tcx>
|
||||
where T : Combineable<'tcx> + Repr<'tcx>
|
||||
{
|
||||
debug!("can_equate({}, {})", a.repr(self.tcx), b.repr(self.tcx));
|
||||
|
|
@ -1118,7 +1067,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
values: Types(expected_found(true, e, e)) };
|
||||
let eq = self.equate(true, trace);
|
||||
Combineable::combine(&eq, a, b)
|
||||
}).to_ures()
|
||||
}).map(|_| ())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ pub use self::RegionResolutionError::*;
|
|||
pub use self::VarValue::*;
|
||||
use self::Classification::*;
|
||||
|
||||
use super::cres;
|
||||
use super::CombineResult;
|
||||
use super::{RegionVariableOrigin, SubregionOrigin, TypeTrace, MiscVariable};
|
||||
|
||||
use middle::region;
|
||||
|
|
@ -799,7 +799,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
/// regions are given as argument, in any order, a consistent result is returned.
|
||||
fn lub_free_regions(&self,
|
||||
a: &FreeRegion,
|
||||
b: &FreeRegion) -> ty::Region
|
||||
b: &FreeRegion)
|
||||
-> ty::Region
|
||||
{
|
||||
return match a.cmp(b) {
|
||||
Less => helper(self, a, b),
|
||||
|
|
@ -824,7 +825,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
fn glb_concrete_regions(&self,
|
||||
a: Region,
|
||||
b: Region)
|
||||
-> cres<'tcx, Region> {
|
||||
-> CombineResult<'tcx, Region>
|
||||
{
|
||||
debug!("glb_concrete_regions({:?}, {:?})", a, b);
|
||||
match (a, b) {
|
||||
(ReLateBound(..), _) |
|
||||
|
|
@ -898,7 +900,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
/// returned.
|
||||
fn glb_free_regions(&self,
|
||||
a: &FreeRegion,
|
||||
b: &FreeRegion) -> cres<'tcx, ty::Region>
|
||||
b: &FreeRegion)
|
||||
-> CombineResult<'tcx, ty::Region>
|
||||
{
|
||||
return match a.cmp(b) {
|
||||
Less => helper(self, a, b),
|
||||
|
|
@ -908,7 +911,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
|
||||
fn helper<'a, 'tcx>(this: &RegionVarBindings<'a, 'tcx>,
|
||||
a: &FreeRegion,
|
||||
b: &FreeRegion) -> cres<'tcx, ty::Region>
|
||||
b: &FreeRegion) -> CombineResult<'tcx, ty::Region>
|
||||
{
|
||||
if this.tcx.region_maps.sub_free_region(*a, *b) {
|
||||
Ok(ty::ReFree(*a))
|
||||
|
|
@ -926,7 +929,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
region_a: ty::Region,
|
||||
region_b: ty::Region,
|
||||
scope_a: region::CodeExtent,
|
||||
scope_b: region::CodeExtent) -> cres<'tcx, Region>
|
||||
scope_b: region::CodeExtent)
|
||||
-> CombineResult<'tcx, Region>
|
||||
{
|
||||
// We want to generate the intersection of two
|
||||
// scopes or two free regions. So, if one of
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
use super::combine::*;
|
||||
use super::cres;
|
||||
use super::CombineResult;
|
||||
use super::higher_ranked::HigherRankedRelations;
|
||||
use super::Subtype;
|
||||
use super::type_variable::{SubtypeOf, SupertypeOf};
|
||||
|
|
@ -33,7 +33,7 @@ impl<'f, 'tcx> Combine<'tcx> for Sub<'f, 'tcx> {
|
|||
fn fields<'a>(&'a self) -> &'a CombineFields<'a, 'tcx> { &self.fields }
|
||||
|
||||
fn tys_with_variance(&self, v: ty::Variance, a: Ty<'tcx>, b: Ty<'tcx>)
|
||||
-> cres<'tcx, Ty<'tcx>>
|
||||
-> CombineResult<'tcx, Ty<'tcx>>
|
||||
{
|
||||
match v {
|
||||
ty::Invariant => self.equate().tys(a, b),
|
||||
|
|
@ -44,7 +44,7 @@ impl<'f, 'tcx> Combine<'tcx> for Sub<'f, 'tcx> {
|
|||
}
|
||||
|
||||
fn regions_with_variance(&self, v: ty::Variance, a: ty::Region, b: ty::Region)
|
||||
-> cres<'tcx, ty::Region>
|
||||
-> CombineResult<'tcx, ty::Region>
|
||||
{
|
||||
match v {
|
||||
ty::Invariant => self.equate().regions(a, b),
|
||||
|
|
@ -54,7 +54,7 @@ impl<'f, 'tcx> Combine<'tcx> for Sub<'f, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn regions(&self, a: ty::Region, b: ty::Region) -> cres<'tcx, ty::Region> {
|
||||
fn regions(&self, a: ty::Region, b: ty::Region) -> CombineResult<'tcx, ty::Region> {
|
||||
debug!("{}.regions({}, {})",
|
||||
self.tag(),
|
||||
a.repr(self.tcx()),
|
||||
|
|
@ -63,7 +63,7 @@ impl<'f, 'tcx> Combine<'tcx> for Sub<'f, 'tcx> {
|
|||
Ok(a)
|
||||
}
|
||||
|
||||
fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>> {
|
||||
fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> CombineResult<'tcx, Ty<'tcx>> {
|
||||
debug!("{}.tys({}, {})", self.tag(),
|
||||
a.repr(self.tcx()), b.repr(self.tcx()));
|
||||
if a == b { return Ok(a); }
|
||||
|
|
@ -99,7 +99,7 @@ impl<'f, 'tcx> Combine<'tcx> for Sub<'f, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn binders<T>(&self, a: &ty::Binder<T>, b: &ty::Binder<T>) -> cres<'tcx, ty::Binder<T>>
|
||||
fn binders<T>(&self, a: &ty::Binder<T>, b: &ty::Binder<T>) -> CombineResult<'tcx, ty::Binder<T>>
|
||||
where T : Combineable<'tcx>
|
||||
{
|
||||
self.higher_ranked_sub(a, b)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use std::marker;
|
|||
|
||||
use middle::ty::{expected_found, IntVarValue};
|
||||
use middle::ty::{self, Ty};
|
||||
use middle::infer::{uok, ures};
|
||||
use middle::infer::UnitResult;
|
||||
use middle::infer::InferCtxt;
|
||||
use std::cell::RefCell;
|
||||
use std::fmt::Debug;
|
||||
|
|
@ -236,7 +236,7 @@ pub trait SimplyUnifiable<'tcx> : Clone + PartialEq + Debug {
|
|||
pub fn err<'tcx, V:SimplyUnifiable<'tcx>>(a_is_expected: bool,
|
||||
a_t: V,
|
||||
b_t: V)
|
||||
-> ures<'tcx> {
|
||||
-> UnitResult<'tcx> {
|
||||
if a_is_expected {
|
||||
Err(SimplyUnifiable::to_type_err(
|
||||
ty::expected_found {expected: a_t, found: b_t}))
|
||||
|
|
@ -255,12 +255,12 @@ pub trait InferCtxtMethodsForSimplyUnifiableTypes<'tcx,K,V>
|
|||
a_is_expected: bool,
|
||||
a_id: K,
|
||||
b_id: K)
|
||||
-> ures<'tcx>;
|
||||
-> UnitResult<'tcx>;
|
||||
fn simple_var_t(&self,
|
||||
a_is_expected: bool,
|
||||
a_id: K,
|
||||
b: V)
|
||||
-> ures<'tcx>;
|
||||
-> UnitResult<'tcx>;
|
||||
fn probe_var(&self, a_id: K) -> Option<Ty<'tcx>>;
|
||||
}
|
||||
|
||||
|
|
@ -276,7 +276,7 @@ impl<'a,'tcx,V,K> InferCtxtMethodsForSimplyUnifiableTypes<'tcx,K,V> for InferCtx
|
|||
a_is_expected: bool,
|
||||
a_id: K,
|
||||
b_id: K)
|
||||
-> ures<'tcx>
|
||||
-> UnitResult<'tcx>
|
||||
{
|
||||
let tcx = self.tcx;
|
||||
let table = UnifyKey::unification_table(self);
|
||||
|
|
@ -285,7 +285,7 @@ impl<'a,'tcx,V,K> InferCtxtMethodsForSimplyUnifiableTypes<'tcx,K,V> for InferCtx
|
|||
let a_id = node_a.key.clone();
|
||||
let b_id = node_b.key.clone();
|
||||
|
||||
if a_id == b_id { return uok(); }
|
||||
if a_id == b_id { return Ok(()); }
|
||||
|
||||
let combined = {
|
||||
match (&node_a.value, &node_b.value) {
|
||||
|
|
@ -317,7 +317,7 @@ impl<'a,'tcx,V,K> InferCtxtMethodsForSimplyUnifiableTypes<'tcx,K,V> for InferCtx
|
|||
a_is_expected: bool,
|
||||
a_id: K,
|
||||
b: V)
|
||||
-> ures<'tcx>
|
||||
-> UnitResult<'tcx>
|
||||
{
|
||||
let tcx = self.tcx;
|
||||
let table = UnifyKey::unification_table(self);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
|
||||
use check::{autoderef, FnCtxt, NoPreference, PreferMutLvalue, UnresolvedTypeAction};
|
||||
|
||||
use middle::infer::{self, cres, Coercion, TypeTrace};
|
||||
use middle::infer::{self, CombineResult, Coercion, TypeTrace};
|
||||
use middle::infer::combine::Combine;
|
||||
use middle::infer::sub::Sub;
|
||||
use middle::subst;
|
||||
|
|
@ -79,7 +79,7 @@ struct Coerce<'a, 'tcx: 'a> {
|
|||
trace: TypeTrace<'tcx>
|
||||
}
|
||||
|
||||
type CoerceResult<'tcx> = cres<'tcx, Option<ty::AutoAdjustment<'tcx>>>;
|
||||
type CoerceResult<'tcx> = CombineResult<'tcx, Option<ty::AutoAdjustment<'tcx>>>;
|
||||
|
||||
impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
||||
fn tcx(&self) -> &ty::ctxt<'tcx> {
|
||||
|
|
@ -534,7 +534,7 @@ pub fn mk_assignty<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
expr: &ast::Expr,
|
||||
a: Ty<'tcx>,
|
||||
b: Ty<'tcx>)
|
||||
-> cres<'tcx, ()> {
|
||||
-> CombineResult<'tcx, ()> {
|
||||
debug!("mk_assignty({} -> {})", a.repr(fcx.tcx()), b.repr(fcx.tcx()));
|
||||
let adjustment = try!(indent(|| {
|
||||
fcx.infcx().commit_if_ok(|| {
|
||||
|
|
|
|||
|
|
@ -1130,7 +1130,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// MISCELLANY
|
||||
|
||||
fn make_sub_ty(&self, sub: Ty<'tcx>, sup: Ty<'tcx>) -> infer::ures<'tcx> {
|
||||
fn make_sub_ty(&self, sub: Ty<'tcx>, sup: Ty<'tcx>) -> infer::UnitResult<'tcx> {
|
||||
self.infcx().sub_types(false, infer::Misc(DUMMY_SP), sub, sup)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue