- let ty = self.tcx().type_of(def_id);
- let ty = ty.subst(tcx, substs);
- debug!("relate_type_and_user_type: ty of def-id is {:?}", ty);
- let ty = self.normalize(ty, locations);
-
- self.relate_types(ty, v1, a, locations, category)?;
-
- if let Some(UserSelfTy {
- impl_def_id,
- self_ty,
- }) = user_self_ty
- {
- let impl_self_ty = tcx.type_of(impl_def_id);
- let impl_self_ty = impl_self_ty.subst(tcx, &substs);
- let impl_self_ty = self.normalize(impl_self_ty, locations);
-
- // There may be type variables in `substs` and hence
- // in `impl_self_ty`, but they should all have been
- // resolved to some fixed value during the first call
- // to `relate`, above. Therefore, if we use
- // `resolve_type_vars_if_possible` we should get to
- // something without type variables. This is important
- // because the `b` type in `relate_with_variance`
- // below is not permitted to have inference variables.
- let impl_self_ty = self.infcx.resolve_type_vars_if_possible(&impl_self_ty);
- assert!(!impl_self_ty.has_infer_types());
-
- self.eq_types(self_ty, impl_self_ty, locations, category)?;
-
- self.prove_predicate(
- ty::Predicate::WellFormed(impl_self_ty),
- locations,
- category,
- );
- }
-
- // Prove the predicates coming along with `def_id`.
- //
- // Also, normalize the `instantiated_predicates`
- // because otherwise we wind up with duplicate "type
- // outlives" error messages.
- let instantiated_predicates = tcx.predicates_of(def_id).instantiate(tcx, substs);
- let instantiated_predicates = self.fold_to_region_vid(instantiated_predicates);
- self.normalize_and_prove_instantiated_predicates(
- instantiated_predicates,