/// Populates the type context with all the implementations for the given
/// trait if necessary.
Populates the type context with all the implementations for the given
trait if necessary.
Populates the type context with all the implementations for the given trait if necessary .
pub fn populate_implementations_for_trait_if_necessary(&self, trait_id: DefId) {
        if trait_id.is_local() {
            return
        }
        let def = self.lookup_trait_def(trait_id);
        if def.flags.get().intersects(TraitFlags::IMPLS_VALID) {
            return;
        }
        debug!("populate_implementations_for_trait_if_necessary: searching for {:?}", def);
        if csearch::is_defaulted_trait(&self.sess.cstore, trait_id) {
            self.record_trait_has_default_impl(trait_id);
        }
        csearch::each_implementation_for_trait(&self.sess.cstore, trait_id, |impl_def_id| {
            let impl_items = csearch::get_impl_items(&self.sess.cstore, impl_def_id);
            let trait_ref = self.impl_trait_ref(impl_def_id).unwrap();
            // Record the trait->implementation mapping.
            def.record_impl(self, impl_def_id, trait_ref);
            // For any methods that use a default implementation, add them to
            // the map. This is a bit unfortunate.
            for impl_item_def_id in &impl_items {
                let method_def_id = impl_item_def_id.def_id();
                match self.impl_or_trait_item(method_def_id) {
                    MethodTraitItem(method) => {
                        if let Some(source) = method.provided_source {
                            self.provided_method_sources
                                .borrow_mut()
                                .insert(method_def_id, source);
                        }
                    }
                    _ => {}
                }
            }
            // Store the implementation info.
            self.impl_items.borrow_mut().insert(impl_def_id, impl_items);
        });
        def.flags.set(def.flags.get() | TraitFlags::IMPLS_VALID);
    }
pub fn populate_implementations_for_trait_if_necessary ( & self , trait_id : DefId ) { if trait_id . is_local ( ) { return } let def = self . lookup_trait_def ( trait_id ) ; if def . flags . get ( ) . intersects ( TraitFlags :: IMPLS_VALID ) { return ; } debug ! ( " " def ) ; if csearch :: is_defaulted_trait ( & self . sess . cstore , trait_id ) { self . record_trait_has_default_impl ( trait_id ) ; } csearch :: each_implementation_for_trait ( & self . sess . cstore , trait_id , | impl_def_id | { let impl_items = csearch :: get_impl_items ( & self . sess . cstore , impl_def_id ) ; let trait_ref = self . impl_trait_ref ( impl_def_id ) . unwrap ( ) ; // Record the trait->implementation mapping. def . record_impl ( self , impl_def_id , trait_ref ) ; // For any methods that use a default implementation, add them to // the map. This is a bit unfortunate. for impl_item_def_id in & impl_items { let method_def_id = impl_item_def_id . def_id ( ) ; match self . impl_or_trait_item ( method_def_id ) { MethodTraitItem ( method ) => { if let Some ( source ) = method . provided_source { self . provided_method_sources . borrow_mut ( ) . insert ( method_def_id , source ) ; } } _ => { } } } // Store the implementation info. self . impl_items . borrow_mut ( ) . insert ( impl_def_id , impl_items ) ; } ) ; def . flags . set ( def . flags . get ( ) | TraitFlags :: IMPLS_VALID ) ; }
Populates the type context with all the implementations for the given
trait if necessary.
Populates the type context with all the implementations for the given trait if necessary .
&self
trait_id
DefId