snapshot: &CombinedSnapshot,
value: &T)
-> T
- where T : TypeFoldable<'tcx>
+ where T : TypeFoldable<'tcx> + ty::HasTypeFlags
{
debug_assert!(leak_check(infcx, &skol_map, snapshot).is_ok());
snapshot: &CombinedSnapshot,
value: &T)
-> T
- where T : TypeFoldable<'tcx>
+ where T : TypeFoldable<'tcx> + HasTypeFlags
{
/*! See `higher_ranked::plug_leaks` */
}
}
- pub fn resolve_type_vars_if_possible<T:TypeFoldable<'tcx>>(&self, value: &T) -> T {
+ pub fn resolve_type_vars_if_possible<T>(&self, value: &T) -> T
+ where T: TypeFoldable<'tcx> + HasTypeFlags
+ {
/*!
* Where possible, replaces type/int/float variables in
* `value` with their final value. Note that region variables
* at will.
*/
+ if !value.needs_infer() {
+ return value.clone(); // avoid duplicated subst-folding
+ }
let mut r = resolve::OpportunisticTypeResolver::new(self);
value.fold_with(&mut r)
}
pub fn report_overflow_error<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>,
obligation: &Obligation<'tcx, T>)
-> !
- where T: fmt::Display + TypeFoldable<'tcx>
+ where T: fmt::Display + TypeFoldable<'tcx> + HasTypeFlags
{
let predicate =
infcx.resolve_type_vars_if_possible(&obligation.predicate);
}
}
+impl<'tcx, T: HasTypeFlags> HasTypeFlags for Normalized<'tcx, T> {
+ fn has_type_flags(&self, flags: ty::TypeFlags) -> bool {
+ self.value.has_type_flags(flags) ||
+ self.obligations.has_type_flags(flags)
+ }
+}
+
impl<'tcx, T:fmt::Debug> fmt::Debug for Normalized<'tcx, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Normalized({:?},{:?})",
}
}
+impl HasTypeFlags for abi::Abi {
+ fn has_type_flags(&self, _flags: TypeFlags) -> bool {
+ false
+ }
+}
+
+impl HasTypeFlags for ast::Unsafety {
+ fn has_type_flags(&self, _flags: TypeFlags) -> bool {
+ false
+ }
+}
+
+impl HasTypeFlags for BuiltinBounds {
+ fn has_type_flags(&self, _flags: TypeFlags) -> bool {
+ false
+ }
+}
+
impl<'tcx> HasTypeFlags for ClosureTy<'tcx> {
fn has_type_flags(&self, flags: TypeFlags) -> bool {
self.sig.has_type_flags(flags)
}
}
+impl<'tcx> HasTypeFlags for ExistentialBounds<'tcx> {
+ fn has_type_flags(&self, flags: TypeFlags) -> bool {
+ self.projection_bounds.has_type_flags(flags)
+ }
+}
+
impl<'tcx> HasTypeFlags for ty::InstantiatedPredicates<'tcx> {
fn has_type_flags(&self, flags: TypeFlags) -> bool {
self.predicates.has_type_flags(flags)
}
}
+impl<'tcx> HasTypeFlags for TypeAndMut<'tcx> {
+ fn has_type_flags(&self, flags: TypeFlags) -> bool {
+ self.ty.has_type_flags(flags)
+ }
+}
+
impl<'tcx> HasTypeFlags for TraitRef<'tcx> {
fn has_type_flags(&self, flags: TypeFlags) -> bool {
self.substs.has_type_flags(flags)
//! type equality, etc.
use middle::subst::{ErasedRegions, NonerasedRegions, ParamSpace, Substs};
-use middle::ty::{self, Ty, TypeError};
+use middle::ty::{self, HasTypeFlags, Ty, TypeError};
use middle::ty_fold::TypeFoldable;
use std::rc::Rc;
use syntax::abi;
where T: Relate<'a,'tcx>;
}
-pub trait Relate<'a,'tcx>: TypeFoldable<'tcx> {
+pub trait Relate<'a,'tcx>: TypeFoldable<'tcx> + HasTypeFlags {
fn relate<R:TypeRelation<'a,'tcx>>(relation: &mut R,
a: &Self,
b: &Self)