pub fn trans_fulfill_obligation(self,
                                    span: Span,
                                    trait_ref: ty::PolyTraitRef<'tcx>)
                                    -> Vtable<'tcx, ()>
    {
        // Remove any references to regions; this helps improve caching.
        let trait_ref = self.erase_regions(&trait_ref);

        self.trans_trait_caches.trait_cache.memoize(trait_ref, || {
            debug!("trans::fulfill_obligation(trait_ref={:?}, def_id={:?})",
                   trait_ref, trait_ref.def_id());

            // Do the initial selection for the obligation. This yields the
            // shallow result we are looking for -- that is, what specific impl.
            self.infer_ctxt().enter(|infcx| {
                let mut selcx = SelectionContext::new(&infcx);

                let param_env = ty::ParamEnv::empty(Reveal::All);
                let obligation_cause = ObligationCause::misc(span,
                                                             ast::DUMMY_NODE_ID);
                let obligation = Obligation::new(obligation_cause,
                                                 param_env,
                                                 trait_ref.to_poly_trait_predicate());

                let selection = match selcx.select(&obligation) {
                    Ok(Some(selection)) => selection,
                    Ok(None) => {
                        // Ambiguity can happen when monomorphizing during trans
                        // expands to some humongo type that never occurred
                        // statically -- this humongo type can then overflow,
                        // leading to an ambiguous result. So report this as an
                        // overflow bug, since I believe this is the only case
                        // where ambiguity can result.
                        debug!("Encountered ambiguity selecting `{:?}` during trans, \
                                presuming due to overflow",
                               trait_ref);
                        self.sess.span_fatal(span,
                                            "reached the recursion limit during monomorphization \
                                             (selection ambiguity)");
                    }
                    Err(e) => {
                        span_bug!(span, "Encountered error `{:?}` selecting `{:?}` during trans",
                                  e, trait_ref)
                    }
                };

                debug!("fulfill_obligation: selection={:?}", selection);

                // Currently, we use a fulfillment context to completely resolve
                // all nested obligations. This is because they can inform the
                // inference of the impl's type parameters.
                let mut fulfill_cx = FulfillmentContext::new();
                let vtable = selection.map(|predicate| {
                    debug!("fulfill_obligation: register_predicate_obligation {:?}", predicate);
                    fulfill_cx.register_predicate_obligation(&infcx, predicate);
                });
                let vtable = infcx.drain_fulfillment_cx_or_panic(span, &mut fulfill_cx, &vtable);

                info!("Cache miss: {:?} => {:?}", trait_ref, vtable);
                vtable
            })
        })
    }
/// Attempts to resolve an obligation to a vtable.. The result is
/// a shallow vtable resolution -- meaning that we do not
/// (necessarily) resolve all nested obligations on the impl. Note
/// that type check should guarantee to us that all nested
/// obligations *could be* resolved if we wanted to.
Attempts to resolve an obligation to a vtable.. The result is
a shallow vtable resolution -- meaning that we do not
(necessarily) resolve all nested obligations on the impl. Note
that type check should guarantee to us that all nested
obligations *could be* resolved if we wanted to.
Attempts to resolve an obligation to a vtable .. The result is a shallow vtable resolution -- meaning that we do not ( necessarily ) resolve all nested obligations on the impl . Note that type check should guarantee to us that all nested obligations * could be * resolved if we wanted to .
pub fn trans_fulfill_obligation(self,
                                    span: Span,
                                    trait_ref: ty::PolyTraitRef<'tcx>)
                                    -> Vtable<'tcx, ()>
    {
        // Remove any references to regions; this helps improve caching.
        let trait_ref = self.erase_regions(&trait_ref);
        self.trans_trait_caches.trait_cache.memoize(trait_ref, || {
            debug!("trans::fulfill_obligation(trait_ref={:?}, def_id={:?})",
                   trait_ref, trait_ref.def_id());
            // Do the initial selection for the obligation. This yields the
            // shallow result we are looking for -- that is, what specific impl.
            self.infer_ctxt().enter(|infcx| {
                let mut selcx = SelectionContext::new(&infcx);
                let param_env = ty::ParamEnv::empty(Reveal::All);
                let obligation_cause = ObligationCause::misc(span,
                                                             ast::DUMMY_NODE_ID);
                let obligation = Obligation::new(obligation_cause,
                                                 param_env,
                                                 trait_ref.to_poly_trait_predicate());
                let selection = match selcx.select(&obligation) {
                    Ok(Some(selection)) => selection,
                    Ok(None) => {
                        // Ambiguity can happen when monomorphizing during trans
                        // expands to some humongo type that never occurred
                        // statically -- this humongo type can then overflow,
                        // leading to an ambiguous result. So report this as an
                        // overflow bug, since I believe this is the only case
                        // where ambiguity can result.
                        debug!("Encountered ambiguity selecting `{:?}` during trans, \
                                presuming due to overflow",
                               trait_ref);
                        self.sess.span_fatal(span,
                                            "reached the recursion limit during monomorphization \
                                             (selection ambiguity)");
                    }
                    Err(e) => {
                        span_bug!(span, "Encountered error `{:?}` selecting `{:?}` during trans",
                                  e, trait_ref)
                    }
                };
                debug!("fulfill_obligation: selection={:?}", selection);
                // Currently, we use a fulfillment context to completely resolve
                // all nested obligations. This is because they can inform the
                // inference of the impl's type parameters.
                let mut fulfill_cx = FulfillmentContext::new();
                let vtable = selection.map(|predicate| {
                    debug!("fulfill_obligation: register_predicate_obligation {:?}", predicate);
                    fulfill_cx.register_predicate_obligation(&infcx, predicate);
                });
                let vtable = infcx.drain_fulfillment_cx_or_panic(span, &mut fulfill_cx, &vtable);
                info!("Cache miss: {:?} => {:?}", trait_ref, vtable);
                vtable
            })
        })
    }
pub fn trans_fulfill_obligation ( self , span : Span , trait_ref : ty :: PolyTraitRef < ' tcx > ) -> Vtable < ' tcx , ( ) > { // Remove any references to regions; this helps improve caching. let trait_ref = self . erase_regions ( & trait_ref ) ; self . trans_trait_caches . trait_cache . memoize ( trait_ref , | | { debug ! ( " " trait_ref trait_ref def_id ( ) ) ; // Do the initial selection for the obligation. This yields the // shallow result we are looking for -- that is, what specific impl. self . infer_ctxt ( ) . enter ( | infcx | { let mut selcx = SelectionContext :: new ( & infcx ) ; let param_env = ty :: ParamEnv :: empty ( Reveal :: All ) ; let obligation_cause = ObligationCause :: misc ( span , ast :: DUMMY_NODE_ID ) ; let obligation = Obligation :: new ( obligation_cause , param_env , trait_ref . to_poly_trait_predicate ( ) ) ; let selection = match selcx . select ( & obligation ) { Ok ( Some ( selection ) ) => selection , Ok ( None ) => { // Ambiguity can happen when monomorphizing during trans // expands to some humongo type that never occurred // statically -- this humongo type can then overflow, // leading to an ambiguous result. So report this as an // overflow bug, since I believe this is the only case // where ambiguity can result. debug ! ( " \
 " trait_ref ) ; self . sess . span_fatal ( span , " \
 " ) ; } Err ( e ) => { span_bug ! ( span " " e trait_ref ) } } ; debug ! ( " " selection ) ; // Currently, we use a fulfillment context to completely resolve // all nested obligations. This is because they can inform the // inference of the impl's type parameters. let mut fulfill_cx = FulfillmentContext :: new ( ) ; let vtable = selection . map ( | predicate | { debug ! ( " " predicate ) ; fulfill_cx . register_predicate_obligation ( & infcx , predicate ) ; } ) ; let vtable = infcx . drain_fulfillment_cx_or_panic ( span , & mut fulfill_cx , & vtable ) ; info ! ( " " trait_ref vtable ) ; vtable } ) } ) }
Attempts to resolve an obligation to a vtable..
Attempts to resolve an obligation to a vtable ..
self
span
Span
trait_ref
ty::PolyTraitRef<'tcx>
self
span
Span
trait_ref
ty::PolyTraitRef<'tcx>