fn predicate_can_apply(
        &self,
        param_env: ty::ParamEnv<'tcx>,
        pred: ty::PolyTraitRef<'tcx>,
    ) -> bool {
        struct ParamToVarFolder<'a, 'tcx> {
            infcx: &'a InferCtxt<'a, 'tcx>,
            var_map: FxHashMap<Ty<'tcx>, Ty<'tcx>>,
        }

        impl<'a, 'tcx> TypeFolder<'tcx> for ParamToVarFolder<'a, 'tcx> {
            fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.infcx.tcx }

            fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
                if let ty::Param(ty::ParamTy {name, .. }) = ty.kind {
                    let infcx = self.infcx;
                    self.var_map.entry(ty).or_insert_with(||
                        infcx.next_ty_var(
                            TypeVariableOrigin {
                                kind: TypeVariableOriginKind::TypeParameterDefinition(name, None),
                                span: DUMMY_SP,
                            }
                        )
                    )
                } else {
                    ty.super_fold_with(self)
                }
            }
        }

        self.probe(|_| {
            let mut selcx = SelectionContext::new(self);

            let cleaned_pred = pred.fold_with(&mut ParamToVarFolder {
                infcx: self,
                var_map: Default::default()
            });

            let cleaned_pred = super::project::normalize(
                &mut selcx,
                param_env,
                ObligationCause::dummy(),
                &cleaned_pred
            ).value;

            let obligation = Obligation::new(
                ObligationCause::dummy(),
                param_env,
                cleaned_pred.to_predicate()
            );

            self.predicate_may_hold(&obligation)
        })
    }
/// Returns `true` if the trait predicate may apply for *some* assignment
/// to the type parameters.
Returns `true` if the trait predicate may apply for *some* assignment
to the type parameters.
Returns ` true ` if the trait predicate may apply for * some * assignment to the type parameters .
fn predicate_can_apply(
        &self,
        param_env: ty::ParamEnv<'tcx>,
        pred: ty::PolyTraitRef<'tcx>,
    ) -> bool {
        struct ParamToVarFolder<'a, 'tcx> {
            infcx: &'a InferCtxt<'a, 'tcx>,
            var_map: FxHashMap<Ty<'tcx>, Ty<'tcx>>,
        }
        impl<'a, 'tcx> TypeFolder<'tcx> for ParamToVarFolder<'a, 'tcx> {
            fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.infcx.tcx }
            fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
                if let ty::Param(ty::ParamTy {name, .. }) = ty.kind {
                    let infcx = self.infcx;
                    self.var_map.entry(ty).or_insert_with(||
                        infcx.next_ty_var(
                            TypeVariableOrigin {
                                kind: TypeVariableOriginKind::TypeParameterDefinition(name, None),
                                span: DUMMY_SP,
                            }
                        )
                    )
                } else {
                    ty.super_fold_with(self)
                }
            }
        }
        self.probe(|_| {
            let mut selcx = SelectionContext::new(self);
            let cleaned_pred = pred.fold_with(&mut ParamToVarFolder {
                infcx: self,
                var_map: Default::default()
            });
            let cleaned_pred = super::project::normalize(
                &mut selcx,
                param_env,
                ObligationCause::dummy(),
                &cleaned_pred
            ).value;
            let obligation = Obligation::new(
                ObligationCause::dummy(),
                param_env,
                cleaned_pred.to_predicate()
            );
            self.predicate_may_hold(&obligation)
        })
    }
fn predicate_can_apply ( & self , param_env : ty :: ParamEnv < ' tcx > , pred : ty :: PolyTraitRef < ' tcx > , ) -> bool { struct ParamToVarFolder < ' a , ' tcx > { infcx : & ' a InferCtxt < ' a , ' tcx > , var_map : FxHashMap < Ty < ' tcx > , Ty < ' tcx > > , } impl < ' a , ' tcx > TypeFolder < ' tcx > for ParamToVarFolder < ' a , ' tcx > { fn tcx < ' b > ( & ' b self ) -> TyCtxt < ' tcx > { self . infcx . tcx } fn fold_ty ( & mut self , ty : Ty < ' tcx > ) -> Ty < ' tcx > { if let ty :: Param ( ty :: ParamTy { name , .. } ) = ty . kind { let infcx = self . infcx ; self . var_map . entry ( ty ) . or_insert_with ( | | infcx . next_ty_var ( TypeVariableOrigin { kind : TypeVariableOriginKind :: TypeParameterDefinition ( name , None ) , span : DUMMY_SP , } ) ) } else { ty . super_fold_with ( self ) } } } self . probe ( | _ | { let mut selcx = SelectionContext :: new ( self ) ; let cleaned_pred = pred . fold_with ( & mut ParamToVarFolder { infcx : self , var_map : Default :: default ( ) } ) ; let cleaned_pred = super :: project :: normalize ( & mut selcx , param_env , ObligationCause :: dummy ( ) , & cleaned_pred ) . value ; let obligation = Obligation :: new ( ObligationCause :: dummy ( ) , param_env , cleaned_pred . to_predicate ( ) ) ; self . predicate_may_hold ( & obligation ) } ) }
Returns `true` if the trait predicate may apply for *some* assignment
to the type parameters.
Returns ` true ` if the trait predicate may apply for * some * assignment to the type parameters .
&self
param_env
ty::ParamEnv<'tcx>
pred
ty::PolyTraitRef<'tcx>