fn unify_canonical_vars(
        &self,
        cause: &ObligationCause<'tcx>,
        param_env: ty::ParamEnv<'tcx>,
        variables1: &SmallCanonicalVarValues<'tcx>,
        variables2: impl Fn(CanonicalVar) -> Kind<'tcx>,
    ) -> InferResult<'tcx, ()> {
        self.commit_if_ok(|_| {
            let mut obligations = vec![];
            for (index, value1) in variables1.iter().enumerate() {
                let value2 = variables2(CanonicalVar::new(index));

                match (value1.unpack(), value2.unpack()) {
                    (UnpackedKind::Type(v1), UnpackedKind::Type(v2)) => {
                        obligations
                            .extend(self.at(cause, param_env).eq(v1, v2)?.into_obligations());
                    }
                    (
                        UnpackedKind::Lifetime(ty::ReErased),
                        UnpackedKind::Lifetime(ty::ReErased),
                    ) => {
                        // no action needed
                    }
                    (UnpackedKind::Lifetime(v1), UnpackedKind::Lifetime(v2)) => {
                        obligations
                            .extend(self.at(cause, param_env).eq(v1, v2)?.into_obligations());
                    }
                    _ => {
                        bug!("kind mismatch, cannot unify {:?} and {:?}", value1, value2,);
                    }
                }
            }
            Ok(InferOk {
                value: (),
                obligations,
            })
        })
    }
/// Given two sets of values for the same set of canonical variables, unify them.
/// The second set is produced lazilly by supplying indices from the first set.
Given two sets of values for the same set of canonical variables, unify them.
The second set is produced lazilly by supplying indices from the first set.
Given two sets of values for the same set of canonical variables unify them . The second set is produced lazilly by supplying indices from the first set .
fn unify_canonical_vars(
        &self,
        cause: &ObligationCause<'tcx>,
        param_env: ty::ParamEnv<'tcx>,
        variables1: &SmallCanonicalVarValues<'tcx>,
        variables2: impl Fn(CanonicalVar) -> Kind<'tcx>,
    ) -> InferResult<'tcx, ()> {
        self.commit_if_ok(|_| {
            let mut obligations = vec![];
            for (index, value1) in variables1.iter().enumerate() {
                let value2 = variables2(CanonicalVar::new(index));
                match (value1.unpack(), value2.unpack()) {
                    (UnpackedKind::Type(v1), UnpackedKind::Type(v2)) => {
                        obligations
                            .extend(self.at(cause, param_env).eq(v1, v2)?.into_obligations());
                    }
                    (
                        UnpackedKind::Lifetime(ty::ReErased),
                        UnpackedKind::Lifetime(ty::ReErased),
                    ) => {
                        // no action needed
                    }
                    (UnpackedKind::Lifetime(v1), UnpackedKind::Lifetime(v2)) => {
                        obligations
                            .extend(self.at(cause, param_env).eq(v1, v2)?.into_obligations());
                    }
                    _ => {
                        bug!("kind mismatch, cannot unify {:?} and {:?}", value1, value2,);
                    }
                }
            }
            Ok(InferOk {
                value: (),
                obligations,
            })
        })
    }
fn unify_canonical_vars ( & self , cause : & ObligationCause < ' tcx > , param_env : ty :: ParamEnv < ' tcx > , variables1 : & SmallCanonicalVarValues < ' tcx > , variables2 : impl Fn ( CanonicalVar ) -> Kind < ' tcx > , ) -> InferResult < ' tcx , ( ) > { self . commit_if_ok ( | _ | { let mut obligations = vec ! [ ] ; for ( index , value1 ) in variables1 . iter ( ) . enumerate ( ) { let value2 = variables2 ( CanonicalVar :: new ( index ) ) ; match ( value1 . unpack ( ) , value2 . unpack ( ) ) { ( UnpackedKind :: Type ( v1 ) , UnpackedKind :: Type ( v2 ) ) => { obligations . extend ( self . at ( cause , param_env ) . eq ( v1 , v2 ) ? . into_obligations ( ) ) ; } ( UnpackedKind :: Lifetime ( ty :: ReErased ) , UnpackedKind :: Lifetime ( ty :: ReErased ) , ) => { // no action needed } ( UnpackedKind :: Lifetime ( v1 ) , UnpackedKind :: Lifetime ( v2 ) ) => { obligations . extend ( self . at ( cause , param_env ) . eq ( v1 , v2 ) ? . into_obligations ( ) ) ; } _ => { bug ! ( " " value1 value2 ) ; } } } Ok ( InferOk { value : ( ) , obligations , } ) } ) }
Given two sets of values for the same set of canonical variables, unify them.
Given two sets of values for the same set of canonical variables unify them .
&self
cause
&ObligationCause<'tcx>
param_env
ty::ParamEnv<'tcx>
variables1
&SmallCanonicalVarValues<'tcx>
variables2
impl Fn(CanonicalVar) -> Kind<'tcx>