pub fn for_each_relevant_impl<F: FnMut(DefId)>(self,
                                                   def_id: DefId,
                                                   self_ty: Ty<'tcx>,
                                                   mut f: F)
    {
        let impls = self.trait_impls_of(def_id);

        for &impl_def_id in impls.blanket_impls.iter() {
            f(impl_def_id);
        }

        // simplify_type(.., false) basically replaces type parameters and
        // projections with infer-variables. This is, of course, done on
        // the impl trait-ref when it is instantiated, but not on the
        // predicate trait-ref which is passed here.
        //
        // for example, if we match `S: Copy` against an impl like
        // `impl<T:Copy> Copy for Option<T>`, we replace the type variable
        // in `Option<T>` with an infer variable, to `Option<_>` (this
        // doesn't actually change fast_reject output), but we don't
        // replace `S` with anything - this impl of course can't be
        // selected, and as there are hundreds of similar impls,
        // considering them would significantly harm performance.

        // This depends on the set of all impls for the trait. That is
        // unfortunate. When we get red-green recompilation, we would like
        // to have a way of knowing whether the set of relevant impls
        // changed. The most naive
        // way would be to compute the Vec of relevant impls and see whether
        // it differs between compilations. That shouldn't be too slow by
        // itself - we do quite a bit of work for each relevant impl anyway.
        //
        // If we want to be faster, we could have separate queries for
        // blanket and non-blanket impls, and compare them separately.
        //
        // I think we'll cross that bridge when we get to it.
        if let Some(simp) = fast_reject::simplify_type(self, self_ty, true) {
            if let Some(impls) = impls.non_blanket_impls.get(&simp) {
                for &impl_def_id in impls {
                    f(impl_def_id);
                }
            }
        } else {
            for v in impls.non_blanket_impls.values() {
                for &impl_def_id in v {
                    f(impl_def_id);
                }
            }
        }
    }
/// Iterate over every impl that could possibly match the
/// self-type `self_ty`.
Iterate over every impl that could possibly match the
self-type `self_ty`.
Iterate over every impl that could possibly match the self - type ` self_ty ` .
pub fn for_each_relevant_impl<F: FnMut(DefId)>(self,
                                                   def_id: DefId,
                                                   self_ty: Ty<'tcx>,
                                                   mut f: F)
    {
        let impls = self.trait_impls_of(def_id);
        for &impl_def_id in impls.blanket_impls.iter() {
            f(impl_def_id);
        }
        // simplify_type(.., false) basically replaces type parameters and
        // projections with infer-variables. This is, of course, done on
        // the impl trait-ref when it is instantiated, but not on the
        // predicate trait-ref which is passed here.
        //
        // for example, if we match `S: Copy` against an impl like
        // `impl<T:Copy> Copy for Option<T>`, we replace the type variable
        // in `Option<T>` with an infer variable, to `Option<_>` (this
        // doesn't actually change fast_reject output), but we don't
        // replace `S` with anything - this impl of course can't be
        // selected, and as there are hundreds of similar impls,
        // considering them would significantly harm performance.
        // This depends on the set of all impls for the trait. That is
        // unfortunate. When we get red-green recompilation, we would like
        // to have a way of knowing whether the set of relevant impls
        // changed. The most naive
        // way would be to compute the Vec of relevant impls and see whether
        // it differs between compilations. That shouldn't be too slow by
        // itself - we do quite a bit of work for each relevant impl anyway.
        //
        // If we want to be faster, we could have separate queries for
        // blanket and non-blanket impls, and compare them separately.
        //
        // I think we'll cross that bridge when we get to it.
        if let Some(simp) = fast_reject::simplify_type(self, self_ty, true) {
            if let Some(impls) = impls.non_blanket_impls.get(&simp) {
                for &impl_def_id in impls {
                    f(impl_def_id);
                }
            }
        } else {
            for v in impls.non_blanket_impls.values() {
                for &impl_def_id in v {
                    f(impl_def_id);
                }
            }
        }
    }
pub fn for_each_relevant_impl < F : FnMut ( DefId ) > ( self , def_id : DefId , self_ty : Ty < ' tcx > , mut f : F ) { let impls = self . trait_impls_of ( def_id ) ; for & impl_def_id in impls . blanket_impls . iter ( ) { f ( impl_def_id ) ; } // simplify_type(.., false) basically replaces type parameters and // projections with infer-variables. This is, of course, done on // the impl trait-ref when it is instantiated, but not on the // predicate trait-ref which is passed here. // // for example, if we match `S: Copy` against an impl like // `impl<T:Copy> Copy for Option<T>`, we replace the type variable // in `Option<T>` with an infer variable, to `Option<_>` (this // doesn't actually change fast_reject output), but we don't // replace `S` with anything - this impl of course can't be // selected, and as there are hundreds of similar impls, // considering them would significantly harm performance. // This depends on the set of all impls for the trait. That is // unfortunate. When we get red-green recompilation, we would like // to have a way of knowing whether the set of relevant impls // changed. The most naive // way would be to compute the Vec of relevant impls and see whether // it differs between compilations. That shouldn't be too slow by // itself - we do quite a bit of work for each relevant impl anyway. // // If we want to be faster, we could have separate queries for // blanket and non-blanket impls, and compare them separately. // // I think we'll cross that bridge when we get to it. if let Some ( simp ) = fast_reject :: simplify_type ( self , self_ty , true ) { if let Some ( impls ) = impls . non_blanket_impls . get ( & simp ) { for & impl_def_id in impls { f ( impl_def_id ) ; } } } else { for v in impls . non_blanket_impls . values ( ) { for & impl_def_id in v { f ( impl_def_id ) ; } } } }
Iterate over every impl that could possibly match the
self-type `self_ty`.
Iterate over every impl that could possibly match the self - type ` self_ty ` .
self
def_id
DefId
self_ty
Ty<'tcx>
f
F
self
def_id
DefId
self_ty
Ty<'tcx>
f
F