From 0939837867e77f478dcd3735f3a6ce8823f5fd48 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 9 Mar 2015 16:39:50 -0400 Subject: [PATCH] Rename the cryptic cres and ures types. --- src/librustc/middle/infer/bivariate.rs | 14 +-- src/librustc/middle/infer/combine.rs | 88 +++++++++++------- src/librustc/middle/infer/equate.rs | 12 +-- src/librustc/middle/infer/glb.rs | 12 +-- .../middle/infer/higher_ranked/mod.rs | 14 +-- src/librustc/middle/infer/lattice.rs | 8 +- src/librustc/middle/infer/lub.rs | 12 +-- src/librustc/middle/infer/mod.rs | 93 +++++-------------- .../middle/infer/region_inference/mod.rs | 16 ++-- src/librustc/middle/infer/sub.rs | 12 +-- src/librustc/middle/infer/unify.rs | 14 +-- src/librustc_typeck/check/coercion.rs | 6 +- src/librustc_typeck/check/method/probe.rs | 2 +- 13 files changed, 138 insertions(+), 165 deletions(-) diff --git a/src/librustc/middle/infer/bivariate.rs b/src/librustc/middle/infer/bivariate.rs index 17b0d788590c..91e1fea7ca52 100644 --- a/src/librustc/middle/infer/bivariate.rs +++ b/src/librustc/middle/infer/bivariate.rs @@ -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(&self, a: &ty::Binder, b: &ty::Binder) -> cres<'tcx, ty::Binder> + fn binders(&self, a: &ty::Binder, b: &ty::Binder) -> CombineResult<'tcx, ty::Binder> where T : Combineable<'tcx> { let a1 = ty::erase_late_bound_regions(self.tcx(), a); diff --git a/src/librustc/middle/infer/combine.rs b/src/librustc/middle/infer/combine.rs index 9aa17b2b1d9f..220a23b183a9 100644 --- a/src/librustc/middle/infer/combine.rs +++ b/src/librustc/middle/infer/combine.rs @@ -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>> + -> CombineResult<'tcx, Vec>> { 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> + -> CombineResult<'tcx, Vec> { 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>> + -> CombineResult<'tcx, Vec>> 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>, b: &Vec>) - -> cres<'tcx, Vec>> + -> CombineResult<'tcx, Vec>> { // 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(&self, a: &ty::Binder, b: &ty::Binder) -> cres<'tcx, ty::Binder> + fn binders(&self, a: &ty::Binder, b: &ty::Binder) -> CombineResult<'tcx, ty::Binder> 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>(combiner: &C, a: &Self, b: &Self) -> cres<'tcx, Self>; + fn combine>(combiner: &C, a: &Self, b: &Self) -> CombineResult<'tcx, Self>; } impl<'tcx,T> Combineable<'tcx> for Rc @@ -380,7 +380,7 @@ impl<'tcx,T> Combineable<'tcx> for Rc fn combine(combiner: &C, a: &Rc, b: &Rc) - -> cres<'tcx, Rc> + -> CombineResult<'tcx, Rc> 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(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(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(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(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(&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(&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()) + } + }) + } +} + diff --git a/src/librustc/middle/infer/equate.rs b/src/librustc/middle/infer/equate.rs index 59ed2dfd24f2..59394d1dd371 100644 --- a/src/librustc/middle/infer/equate.rs +++ b/src/librustc/middle/infer/equate.rs @@ -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(&self, a: &ty::Binder, b: &ty::Binder) -> cres<'tcx, ty::Binder> + fn binders(&self, a: &ty::Binder, b: &ty::Binder) -> CombineResult<'tcx, ty::Binder> where T : Combineable<'tcx> { try!(self.sub().binders(a, b)); diff --git a/src/librustc/middle/infer/glb.rs b/src/librustc/middle/infer/glb.rs index 3b83d37f5823..28c0b4df7f40 100644 --- a/src/librustc/middle/infer/glb.rs +++ b/src/librustc/middle/infer/glb.rs @@ -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(&self, a: &ty::Binder, b: &ty::Binder) -> cres<'tcx, ty::Binder> + fn binders(&self, a: &ty::Binder, b: &ty::Binder) -> CombineResult<'tcx, ty::Binder> where T : Combineable<'tcx> { self.higher_ranked_glb(a, b) diff --git a/src/librustc/middle/infer/higher_ranked/mod.rs b/src/librustc/middle/infer/higher_ranked/mod.rs index 16b387330b9e..3754f52d0585 100644 --- a/src/librustc/middle/infer/higher_ranked/mod.rs +++ b/src/librustc/middle/infer/higher_ranked/mod.rs @@ -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(&self, a: &Binder, b: &Binder) -> cres<'tcx, Binder> + fn higher_ranked_sub(&self, a: &Binder, b: &Binder) -> CombineResult<'tcx, Binder> where T : Combineable<'tcx>; - fn higher_ranked_lub(&self, a: &Binder, b: &Binder) -> cres<'tcx, Binder> + fn higher_ranked_lub(&self, a: &Binder, b: &Binder) -> CombineResult<'tcx, Binder> where T : Combineable<'tcx>; - fn higher_ranked_glb(&self, a: &Binder, b: &Binder) -> cres<'tcx, Binder> + fn higher_ranked_glb(&self, a: &Binder, b: &Binder) -> CombineResult<'tcx, Binder> where T : Combineable<'tcx>; } @@ -44,7 +44,7 @@ impl<'tcx,C> HigherRankedRelations<'tcx> for C where C : Combine<'tcx> { fn higher_ranked_sub(&self, a: &Binder, b: &Binder) - -> cres<'tcx, Binder> + -> CombineResult<'tcx, Binder> 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(&self, a: &Binder, b: &Binder) -> cres<'tcx, Binder> + fn higher_ranked_lub(&self, a: &Binder, b: &Binder) -> CombineResult<'tcx, Binder> 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(&self, a: &Binder, b: &Binder) -> cres<'tcx, Binder> + fn higher_ranked_glb(&self, a: &Binder, b: &Binder) -> CombineResult<'tcx, Binder> where T : Combineable<'tcx> { debug!("{}.higher_ranked_glb({}, {})", diff --git a/src/librustc/middle/infer/lattice.rs b/src/librustc/middle/infer/lattice.rs index 9c764628c14f..6cbf20f26aef 100644 --- a/src/librustc/middle/infer/lattice.rs +++ b/src/librustc/middle/infer/lattice.rs @@ -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(), diff --git a/src/librustc/middle/infer/lub.rs b/src/librustc/middle/infer/lub.rs index 5000ab32ff67..123b6cbcc0a6 100644 --- a/src/librustc/middle/infer/lub.rs +++ b/src/librustc/middle/infer/lub.rs @@ -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(&self, a: &ty::Binder, b: &ty::Binder) -> cres<'tcx, ty::Binder> + fn binders(&self, a: &ty::Binder, b: &ty::Binder) -> CombineResult<'tcx, ty::Binder> where T : Combineable<'tcx> { self.higher_ranked_lub(a, b) diff --git a/src/librustc/middle/infer/mod.rs b/src/librustc/middle/infer/mod.rs index 4cc9b65c2dab..bb94d95dc571 100644 --- a/src/librustc/middle/infer/mod.rs +++ b/src/librustc/middle/infer/mod.rs @@ -63,8 +63,8 @@ pub mod unify; pub type Bound = Option; -pub type cres<'tcx, T> = Result>; // "combine result" -pub type ures<'tcx> = cres<'tcx, ()>; // "unify result" +pub type CombineResult<'tcx, T> = Result>; // "combine result" +pub type UnitResult<'tcx> = CombineResult<'tcx, ()>; // "unify result" pub type fres = Result; // "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(a_is_expected: bool, } } -trait then<'tcx> { - fn then(&self, f: F) -> Result> where - T: Clone, - F: FnOnce() -> Result>; -} - -impl<'tcx> then<'tcx> for ures<'tcx> { - fn then(&self, f: F) -> Result> where - T: Clone, - F: FnOnce() -> Result>, - { - 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(&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(&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>, b: Rc>) - -> 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(&self, a: &T, b: &T) -> ures<'tcx> + pub fn can_equate(&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(|_| ()) } } diff --git a/src/librustc/middle/infer/region_inference/mod.rs b/src/librustc/middle/infer/region_inference/mod.rs index c432d114b6ee..e7c5d1111a21 100644 --- a/src/librustc/middle/infer/region_inference/mod.rs +++ b/src/librustc/middle/infer/region_inference/mod.rs @@ -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 diff --git a/src/librustc/middle/infer/sub.rs b/src/librustc/middle/infer/sub.rs index 5d23fe3f1348..d58a911e8606 100644 --- a/src/librustc/middle/infer/sub.rs +++ b/src/librustc/middle/infer/sub.rs @@ -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(&self, a: &ty::Binder, b: &ty::Binder) -> cres<'tcx, ty::Binder> + fn binders(&self, a: &ty::Binder, b: &ty::Binder) -> CombineResult<'tcx, ty::Binder> where T : Combineable<'tcx> { self.higher_ranked_sub(a, b) diff --git a/src/librustc/middle/infer/unify.rs b/src/librustc/middle/infer/unify.rs index 8a736d47b5d8..de96e9b49fee 100644 --- a/src/librustc/middle/infer/unify.rs +++ b/src/librustc/middle/infer/unify.rs @@ -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>; } @@ -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); diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index ae1dbbb1b00a..d48927c61d2c 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -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>>; +type CoerceResult<'tcx> = CombineResult<'tcx, Option>>; 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(|| { diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 6349ea57f2ff..e203019bd063 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -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) }