From: Masood Malekghassemi Date: Mon, 25 Jul 2016 21:19:14 +0000 (-0700) Subject: Rename infcx lifetimes in inference relations X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=5e390322c3ca016469eca9b5dc8ce761a9786a0b;p=rust.git Rename infcx lifetimes in inference relations --- diff --git a/src/librustc/infer/bivariate.rs b/src/librustc/infer/bivariate.rs index 96b14a6c321..610e25e0f8a 100644 --- a/src/librustc/infer/bivariate.rs +++ b/src/librustc/infer/bivariate.rs @@ -32,20 +32,20 @@ use ty::TyVar; use ty::relate::{Relate, RelateResult, TypeRelation}; -pub struct Bivariate<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - fields: CombineFields<'a, 'gcx, 'tcx> +pub struct Bivariate<'infcx, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> { + fields: CombineFields<'infcx, 'gcx, 'tcx> } -impl<'a, 'gcx, 'tcx> Bivariate<'a, 'gcx, 'tcx> { - pub fn new(fields: CombineFields<'a, 'gcx, 'tcx>) -> Bivariate<'a, 'gcx, 'tcx> { +impl<'infcx, 'gcx, 'tcx> Bivariate<'infcx, 'gcx, 'tcx> { + pub fn new(fields: CombineFields<'infcx, 'gcx, 'tcx>) -> Bivariate<'infcx, 'gcx, 'tcx> { Bivariate { fields: fields } } } -impl<'a, 'gcx, 'tcx> TypeRelation<'a, 'gcx, 'tcx> for Bivariate<'a, 'gcx, 'tcx> { +impl<'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx> for Bivariate<'infcx, 'gcx, 'tcx> { fn tag(&self) -> &'static str { "Bivariate" } - fn tcx(&self) -> TyCtxt<'a, 'gcx, 'tcx> { self.fields.tcx() } + fn tcx(&self) -> TyCtxt<'infcx, 'gcx, 'tcx> { self.fields.tcx() } fn a_is_expected(&self) -> bool { self.fields.a_is_expected } diff --git a/src/librustc/infer/combine.rs b/src/librustc/infer/combine.rs index c9235d063cb..36ea228956d 100644 --- a/src/librustc/infer/combine.rs +++ b/src/librustc/infer/combine.rs @@ -52,21 +52,21 @@ use syntax_pos::Span; #[derive(Clone)] -pub struct CombineFields<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - pub infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, +pub struct CombineFields<'infcx, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> { + pub infcx: &'infcx InferCtxt<'infcx, 'gcx, 'tcx>, pub a_is_expected: bool, pub trace: TypeTrace<'tcx>, pub cause: Option, pub obligations: PredicateObligations<'tcx>, } -impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { +impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> { pub fn super_combine_tys(&self, relation: &mut R, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> - where R: TypeRelation<'a, 'gcx, 'tcx> + where R: TypeRelation<'infcx, 'gcx, 'tcx> { let a_is_expected = relation.a_is_expected(); @@ -150,35 +150,35 @@ fn unify_float_variable(&self, } } -impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> { - pub fn tcx(&self) -> TyCtxt<'a, 'gcx, 'tcx> { +impl<'infcx, 'gcx, 'tcx> CombineFields<'infcx, 'gcx, 'tcx> { + pub fn tcx(&self) -> TyCtxt<'infcx, 'gcx, 'tcx> { self.infcx.tcx } - pub fn switch_expected(&self) -> CombineFields<'a, 'gcx, 'tcx> { + pub fn switch_expected(&self) -> CombineFields<'infcx, 'gcx, 'tcx> { CombineFields { a_is_expected: !self.a_is_expected, ..(*self).clone() } } - pub fn equate(&self) -> Equate<'a, 'gcx, 'tcx> { + pub fn equate(&self) -> Equate<'infcx, 'gcx, 'tcx> { Equate::new(self.clone()) } - pub fn bivariate(&self) -> Bivariate<'a, 'gcx, 'tcx> { + pub fn bivariate(&self) -> Bivariate<'infcx, 'gcx, 'tcx> { Bivariate::new(self.clone()) } - pub fn sub(&self) -> Sub<'a, 'gcx, 'tcx> { + pub fn sub(&self) -> Sub<'infcx, 'gcx, 'tcx> { Sub::new(self.clone()) } - pub fn lub(&self) -> Lub<'a, 'gcx, 'tcx> { + pub fn lub(&self) -> Lub<'infcx, 'gcx, 'tcx> { Lub::new(self.clone()) } - pub fn glb(&self) -> Glb<'a, 'gcx, 'tcx> { + pub fn glb(&self) -> Glb<'infcx, 'gcx, 'tcx> { Glb::new(self.clone()) } diff --git a/src/librustc/infer/equate.rs b/src/librustc/infer/equate.rs index 408f22cf15c..f3dc44e8efd 100644 --- a/src/librustc/infer/equate.rs +++ b/src/librustc/infer/equate.rs @@ -18,12 +18,12 @@ use traits::PredicateObligations; /// Ensures `a` is made equal to `b`. Returns `a` on success. -pub struct Equate<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - fields: CombineFields<'a, 'gcx, 'tcx> +pub struct Equate<'infcx, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> { + fields: CombineFields<'infcx, 'gcx, 'tcx> } -impl<'a, 'gcx, 'tcx> Equate<'a, 'gcx, 'tcx> { - pub fn new(fields: CombineFields<'a, 'gcx, 'tcx>) -> Equate<'a, 'gcx, 'tcx> { +impl<'infcx, 'gcx, 'tcx> Equate<'infcx, 'gcx, 'tcx> { + pub fn new(fields: CombineFields<'infcx, 'gcx, 'tcx>) -> Equate<'infcx, 'gcx, 'tcx> { Equate { fields: fields } } @@ -32,10 +32,10 @@ pub fn obligations(self) -> PredicateObligations<'tcx> { } } -impl<'a, 'gcx, 'tcx> TypeRelation<'a, 'gcx, 'tcx> for Equate<'a, 'gcx, 'tcx> { +impl<'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx> for Equate<'infcx, 'gcx, 'tcx> { fn tag(&self) -> &'static str { "Equate" } - fn tcx(&self) -> TyCtxt<'a, 'gcx, 'tcx> { self.fields.tcx() } + fn tcx(&self) -> TyCtxt<'infcx, 'gcx, 'tcx> { self.fields.tcx() } fn a_is_expected(&self) -> bool { self.fields.a_is_expected } diff --git a/src/librustc/infer/glb.rs b/src/librustc/infer/glb.rs index b7085f0829f..51386083ab3 100644 --- a/src/librustc/infer/glb.rs +++ b/src/librustc/infer/glb.rs @@ -18,12 +18,12 @@ use traits::PredicateObligations; /// "Greatest lower bound" (common subtype) -pub struct Glb<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - fields: CombineFields<'a, 'gcx, 'tcx> +pub struct Glb<'infcx, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> { + fields: CombineFields<'infcx, 'gcx, 'tcx> } -impl<'a, 'gcx, 'tcx> Glb<'a, 'gcx, 'tcx> { - pub fn new(fields: CombineFields<'a, 'gcx, 'tcx>) -> Glb<'a, 'gcx, 'tcx> { +impl<'infcx, 'gcx, 'tcx> Glb<'infcx, 'gcx, 'tcx> { + pub fn new(fields: CombineFields<'infcx, 'gcx, 'tcx>) -> Glb<'infcx, 'gcx, 'tcx> { Glb { fields: fields } } @@ -32,10 +32,10 @@ pub fn obligations(self) -> PredicateObligations<'tcx> { } } -impl<'a, 'gcx, 'tcx> TypeRelation<'a, 'gcx, 'tcx> for Glb<'a, 'gcx, 'tcx> { +impl<'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx> for Glb<'infcx, 'gcx, 'tcx> { fn tag(&self) -> &'static str { "Glb" } - fn tcx(&self) -> TyCtxt<'a, 'gcx, 'tcx> { self.fields.tcx() } + fn tcx(&self) -> TyCtxt<'infcx, 'gcx, 'tcx> { self.fields.tcx() } fn a_is_expected(&self) -> bool { self.fields.a_is_expected } @@ -75,8 +75,8 @@ fn binders(&mut self, a: &ty::Binder, b: &ty::Binder) } } -impl<'a, 'gcx, 'tcx> LatticeDir<'a, 'gcx, 'tcx> for Glb<'a, 'gcx, 'tcx> { - fn infcx(&self) -> &'a InferCtxt<'a, 'gcx, 'tcx> { +impl<'infcx, 'gcx, 'tcx> LatticeDir<'infcx, 'gcx, 'tcx> for Glb<'infcx, 'gcx, 'tcx> { + fn infcx(&self) -> &'infcx InferCtxt<'infcx, 'gcx, 'tcx> { self.fields.infcx } diff --git a/src/librustc/infer/lub.rs b/src/librustc/infer/lub.rs index bd46f3a26a2..bd87c91dea5 100644 --- a/src/librustc/infer/lub.rs +++ b/src/librustc/infer/lub.rs @@ -18,12 +18,12 @@ use traits::PredicateObligations; /// "Least upper bound" (common supertype) -pub struct Lub<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - fields: CombineFields<'a, 'gcx, 'tcx> +pub struct Lub<'infcx, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> { + fields: CombineFields<'infcx, 'gcx, 'tcx> } -impl<'a, 'gcx, 'tcx> Lub<'a, 'gcx, 'tcx> { - pub fn new(fields: CombineFields<'a, 'gcx, 'tcx>) -> Lub<'a, 'gcx, 'tcx> { +impl<'infcx, 'gcx, 'tcx> Lub<'infcx, 'gcx, 'tcx> { + pub fn new(fields: CombineFields<'infcx, 'gcx, 'tcx>) -> Lub<'infcx, 'gcx, 'tcx> { Lub { fields: fields } } @@ -32,10 +32,10 @@ pub fn obligations(self) -> PredicateObligations<'tcx> { } } -impl<'a, 'gcx, 'tcx> TypeRelation<'a, 'gcx, 'tcx> for Lub<'a, 'gcx, 'tcx> { +impl<'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx> for Lub<'infcx, 'gcx, 'tcx> { fn tag(&self) -> &'static str { "Lub" } - fn tcx(&self) -> TyCtxt<'a, 'gcx, 'tcx> { self.fields.tcx() } + fn tcx(&self) -> TyCtxt<'infcx, 'gcx, 'tcx> { self.fields.tcx() } fn a_is_expected(&self) -> bool { self.fields.a_is_expected } @@ -75,8 +75,8 @@ fn binders(&mut self, a: &ty::Binder, b: &ty::Binder) } } -impl<'a, 'gcx, 'tcx> LatticeDir<'a, 'gcx, 'tcx> for Lub<'a, 'gcx, 'tcx> { - fn infcx(&self) -> &'a InferCtxt<'a, 'gcx, 'tcx> { +impl<'infcx, 'gcx, 'tcx> LatticeDir<'infcx, 'gcx, 'tcx> for Lub<'infcx, 'gcx, 'tcx> { + fn infcx(&self) -> &'infcx InferCtxt<'infcx, 'gcx, 'tcx> { self.fields.infcx } diff --git a/src/librustc/infer/sub.rs b/src/librustc/infer/sub.rs index 680dd0d6355..404763b3bd3 100644 --- a/src/librustc/infer/sub.rs +++ b/src/librustc/infer/sub.rs @@ -19,12 +19,12 @@ use std::mem; /// Ensures `a` is made a subtype of `b`. Returns `a` on success. -pub struct Sub<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - fields: CombineFields<'a, 'gcx, 'tcx>, +pub struct Sub<'infcx, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> { + fields: CombineFields<'infcx, 'gcx, 'tcx>, } -impl<'a, 'gcx, 'tcx> Sub<'a, 'gcx, 'tcx> { - pub fn new(f: CombineFields<'a, 'gcx, 'tcx>) -> Sub<'a, 'gcx, 'tcx> { +impl<'infcx, 'gcx, 'tcx> Sub<'infcx, 'gcx, 'tcx> { + pub fn new(f: CombineFields<'infcx, 'gcx, 'tcx>) -> Sub<'infcx, 'gcx, 'tcx> { Sub { fields: f } } @@ -33,9 +33,9 @@ pub fn obligations(self) -> PredicateObligations<'tcx> { } } -impl<'a, 'gcx, 'tcx> TypeRelation<'a, 'gcx, 'tcx> for Sub<'a, 'gcx, 'tcx> { +impl<'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx> for Sub<'infcx, 'gcx, 'tcx> { fn tag(&self) -> &'static str { "Sub" } - fn tcx(&self) -> TyCtxt<'a, 'gcx, 'tcx> { self.fields.infcx.tcx } + fn tcx(&self) -> TyCtxt<'infcx, 'gcx, 'tcx> { self.fields.infcx.tcx } fn a_is_expected(&self) -> bool { self.fields.a_is_expected } fn with_cause(&mut self, cause: Cause, f: F) -> R