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 traits::{self, ObligationCause, PredicateObligations};
use rustc_data_structures::unify as ut;
use std::cell::{Cell, RefCell, Ref, RefMut};
use std::collections::BTreeMap;
#[derive(Clone, Debug)]
pub enum ValuePairs<'tcx> {
Types(ExpectedFound<Ty<'tcx>>),
+ Regions(ExpectedFound<ty::Region<'tcx>>),
TraitRefs(ExpectedFound<ty::TraitRef<'tcx>>),
PolyTraitRefs(ExpectedFound<ty::PolyTraitRef<'tcx>>),
}
/// Helper trait for shortening the lifetimes inside a
/// value for post-type-checking normalization.
+///
+/// This trait offers a normalization method where the inputs and
+/// outputs both have the `'gcx` lifetime; the implementations
+/// internally create inference contexts and/or lift as needed.
pub trait TransNormalize<'gcx>: TypeFoldable<'gcx> {
fn trans_normalize<'a, 'tcx>(&self,
infcx: &InferCtxt<'a, 'gcx, 'tcx>,
{
debug!("fully_normalize_associated_types_in(t={:?})", value);
- let param_env = ty::ParamEnv::empty(Reveal::All);
+ let param_env = ty::ParamEnv::reveal_all();
let value = self.erase_regions(value);
if !value.has_projections() {
}
self.infer_ctxt().enter(|infcx| {
- value.trans_normalize(&infcx, env.reveal_all())
+ value.trans_normalize(&infcx, env.with_reveal_all())
})
}
}
// it can be resolved to an int/float variable, which
// can then be recursively resolved, hence the
// recursion. Note though that we prevent type
- // variables from unifying to other type variables
+ // variables from unifyxing to other type variables
// directly (though they may be embedded
// structurally), and we prevent cycles in any case,
// so this recursion should always be of very limited
}
}
-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<V: TypeVisitor<'tcx>>(&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),
- }
- }
-}
-
-impl<'tcx> TypeFoldable<'tcx> for TypeTrace<'tcx> {
- fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
- TypeTrace {
- cause: self.cause.fold_with(folder),
- values: self.values.fold_with(folder)
- }
- }
-
- fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
- self.cause.visit_with(visitor) || self.values.visit_with(visitor)
+EnumTypeFoldableImpl! {
+ impl<'tcx> TypeFoldable<'tcx> for ValuePairs<'tcx> {
+ (ValuePairs::Types)(a),
+ (ValuePairs::Regions)(a),
+ (ValuePairs::TraitRefs)(a),
+ (ValuePairs::PolyTraitRefs)(a),
}
}