]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_trait_selection/src/traits/util.rs
Rollup merge of #105514 - estebank:is_visible, r=oli-obk
[rust.git] / compiler / rustc_trait_selection / src / traits / util.rs
index a06db4c274831fdf76f01069852c93adadc6e08d..f3ca6a6c779a06b9ca34b584dde18fe5775f0516 100644 (file)
@@ -8,8 +8,8 @@
 use rustc_middle::ty::{self, ImplSubject, ToPredicate, Ty, TyCtxt, TypeVisitable};
 use rustc_middle::ty::{GenericArg, SubstsRef};
 
+use super::NormalizeExt;
 use super::{Obligation, ObligationCause, PredicateObligation, SelectionContext};
-use crate::infer::InferCtxtExt;
 use rustc_infer::infer::InferOk;
 pub use rustc_infer::traits::{self, util::*};
 
@@ -202,15 +202,13 @@ pub fn impl_subject_and_oblig<'a, 'tcx>(
 ) -> (ImplSubject<'tcx>, impl Iterator<Item = PredicateObligation<'tcx>>) {
     let subject = selcx.tcx().bound_impl_subject(impl_def_id);
     let subject = subject.subst(selcx.tcx(), impl_substs);
-    let InferOk { value: subject, obligations: normalization_obligations1 } = selcx
-        .infcx
-        .partially_normalize_associated_types_in(ObligationCause::dummy(), param_env, subject);
+    let InferOk { value: subject, obligations: normalization_obligations1 } =
+        selcx.infcx.at(&ObligationCause::dummy(), param_env).normalize(subject);
 
     let predicates = selcx.tcx().predicates_of(impl_def_id);
     let predicates = predicates.instantiate(selcx.tcx(), impl_substs);
-    let InferOk { value: predicates, obligations: normalization_obligations2 } = selcx
-        .infcx
-        .partially_normalize_associated_types_in(ObligationCause::dummy(), param_env, predicates);
+    let InferOk { value: predicates, obligations: normalization_obligations2 } =
+        selcx.infcx.at(&ObligationCause::dummy(), param_env).normalize(predicates);
     let impl_obligations =
         super::predicates_for_generics(|_, _| ObligationCause::dummy(), param_env, predicates);
 
@@ -263,16 +261,6 @@ pub fn upcast_choices<'tcx>(
     supertraits(tcx, source_trait_ref).filter(|r| r.def_id() == target_trait_def_id).collect()
 }
 
-/// Given a trait `trait_ref`, returns the number of vtable entries
-/// that come from `trait_ref`, excluding its supertraits. Used in
-/// computing the vtable base for an upcast trait of a trait object.
-pub fn count_own_vtable_entries<'tcx>(
-    tcx: TyCtxt<'tcx>,
-    trait_ref: ty::PolyTraitRef<'tcx>,
-) -> usize {
-    tcx.own_existential_vtable_entries(trait_ref.def_id()).len()
-}
-
 /// Given an upcast trait object described by `object`, returns the
 /// index of the method `method_def_id` (which should be part of
 /// `object.upcast_trait_ref`) within the vtable for `object`.