diff --git a/src/librustc/infer/at.rs b/src/librustc/infer/at.rs index 3fd7ee27672..d9fbf4aa514 100644 --- a/src/librustc/infer/at.rs +++ b/src/librustc/infer/at.rs @@ -281,6 +281,20 @@ impl<'tcx> ToTrace<'tcx> for Ty<'tcx> { } } +impl<'tcx> ToTrace<'tcx> for ty::Region<'tcx> { + fn to_trace(cause: &ObligationCause<'tcx>, + a_is_expected: bool, + a: Self, + b: Self) + -> TypeTrace<'tcx> + { + TypeTrace { + cause: cause.clone(), + values: Regions(ExpectedFound::new(a_is_expected, a, b)) + } + } +} + impl<'tcx> ToTrace<'tcx> for ty::TraitRef<'tcx> { fn to_trace(cause: &ObligationCause<'tcx>, a_is_expected: bool, diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 52caf46878b..07551c4ebd3 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -975,6 +975,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { ) -> Option<(DiagnosticStyledString, DiagnosticStyledString)> { match *values { infer::Types(ref exp_found) => self.expected_found_str_ty(exp_found), + infer::Regions(ref exp_found) => self.expected_found_str(exp_found), infer::TraitRefs(ref exp_found) => self.expected_found_str(exp_found), infer::PolyTraitRefs(ref exp_found) => self.expected_found_str(exp_found), } diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index d5afd6e9d3e..d952e430f61 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -26,7 +26,7 @@ use ty::subst::Substs; use ty::{TyVid, IntVid, FloatVid}; use ty::{self, Ty, TyCtxt}; use ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric}; -use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; +use ty::fold::TypeFoldable; use ty::relate::RelateResult; use traits::{self, ObligationCause, PredicateObligations, Reveal}; use rustc_data_structures::unify as ut; @@ -191,6 +191,7 @@ pub type SkolemizationMap<'tcx> = BTreeMap>; #[derive(Clone, Debug)] pub enum ValuePairs<'tcx> { Types(ExpectedFound>), + Regions(ExpectedFound>), TraitRefs(ExpectedFound>), PolyTraitRefs(ExpectedFound>), } @@ -1623,27 +1624,12 @@ impl RegionVariableOrigin { } } -impl<'tcx> TypeFoldable<'tcx> for ValuePairs<'tcx> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { - match *self { - ValuePairs::Types(ref ef) => { - ValuePairs::Types(ef.fold_with(folder)) - } - ValuePairs::TraitRefs(ref ef) => { - ValuePairs::TraitRefs(ef.fold_with(folder)) - } - ValuePairs::PolyTraitRefs(ref ef) => { - ValuePairs::PolyTraitRefs(ef.fold_with(folder)) - } - } - } - - fn super_visit_with>(&self, visitor: &mut V) -> bool { - match *self { - ValuePairs::Types(ref ef) => ef.visit_with(visitor), - ValuePairs::TraitRefs(ref ef) => ef.visit_with(visitor), - ValuePairs::PolyTraitRefs(ref ef) => ef.visit_with(visitor), - } +EnumTypeFoldableImpl! { + impl<'tcx> TypeFoldable<'tcx> for ValuePairs<'tcx> { + (ValuePairs::Types)(a), + (ValuePairs::Regions)(a), + (ValuePairs::TraitRefs)(a), + (ValuePairs::PolyTraitRefs)(a), } }