/// Creates a `TransItem` for each method that is referenced by the vtable for
/// the given trait/impl pair.
Creates a `TransItem` for each method that is referenced by the vtable for
the given trait/impl pair.
Creates a ` TransItem ` for each method that is referenced by the vtable for the given trait / impl pair .
fn create_trans_items_for_vtable_methods<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
                                                   trait_ty: ty::Ty<'tcx>,
                                                   impl_ty: ty::Ty<'tcx>,
                                                   output: &mut Vec<TransItem<'tcx>>) {
    assert!(!trait_ty.needs_subst() && !impl_ty.needs_subst());
    if let ty::TyTrait(ref trait_ty) = trait_ty.sty {
        let poly_trait_ref = trait_ty.principal_trait_ref_with_self_ty(scx.tcx(),
                                                                       impl_ty);
        // Walk all methods of the trait, including those of its supertraits
        for trait_ref in traits::supertraits(scx.tcx(), poly_trait_ref) {
            let vtable = fulfill_obligation(scx, DUMMY_SP, trait_ref);
            match vtable {
                traits::VtableImpl(
                    traits::VtableImplData {
                        impl_def_id,
                        substs,
                        nested: _ }) => {
                    let items = meth::get_vtable_methods(scx.tcx(), impl_def_id, substs)
                        .into_iter()
                        // filter out None values
                        .filter_map(|opt_impl_method| opt_impl_method)
                        // create translation items
                        .filter_map(|impl_method| {
                            if can_have_local_instance(scx.tcx(), impl_method.method.def_id) {
                                Some(create_fn_trans_item(scx.tcx(),
                                    impl_method.method.def_id,
                                    impl_method.substs,
                                    scx.tcx().mk_substs(Substs::empty())))
                            } else {
                                None
                            }
                        });
                    output.extend(items);
                    // Also add the destructor
                    let dg_type = glue::get_drop_glue_type(scx.tcx(),
                                                           trait_ref.self_ty());
                    output.push(TransItem::DropGlue(DropGlueKind::Ty(dg_type)));
                }
                _ => { /* */ }
            }
        }
    }
}
fn create_trans_items_for_vtable_methods < ' a , ' tcx > ( scx : & SharedCrateContext < ' a , ' tcx > , trait_ty : ty :: Ty < ' tcx > , impl_ty : ty :: Ty < ' tcx > , output : & mut Vec < TransItem < ' tcx > > ) { assert ! ( trait_ty needs_subst ( ) impl_ty needs_subst ( ) ) ; if let ty :: TyTrait ( ref trait_ty ) = trait_ty . sty { let poly_trait_ref = trait_ty . principal_trait_ref_with_self_ty ( scx . tcx ( ) , impl_ty ) ; // Walk all methods of the trait, including those of its supertraits for trait_ref in traits :: supertraits ( scx . tcx ( ) , poly_trait_ref ) { let vtable = fulfill_obligation ( scx , DUMMY_SP , trait_ref ) ; match vtable { traits :: VtableImpl ( traits :: VtableImplData { impl_def_id , substs , nested : _ } ) => { let items = meth :: get_vtable_methods ( scx . tcx ( ) , impl_def_id , substs ) . into_iter ( ) // filter out None values . filter_map ( | opt_impl_method | opt_impl_method ) // create translation items . filter_map ( | impl_method | { if can_have_local_instance ( scx . tcx ( ) , impl_method . method . def_id ) { Some ( create_fn_trans_item ( scx . tcx ( ) , impl_method . method . def_id , impl_method . substs , scx . tcx ( ) . mk_substs ( Substs :: empty ( ) ) ) ) } else { None } } ) ; output . extend ( items ) ; // Also add the destructor let dg_type = glue :: get_drop_glue_type ( scx . tcx ( ) , trait_ref . self_ty ( ) ) ; output . push ( TransItem :: DropGlue ( DropGlueKind :: Ty ( dg_type ) ) ) ; } _ => { /* */ } } } } }
Creates a `TransItem` for each method that is referenced by the vtable for
the given trait/impl pair.
Creates a ` TransItem ` for each method that is referenced by the vtable for the given trait / impl pair .
scx
&SharedCrateContext<'a, 'tcx>
trait_ty
ty::Ty<'tcx>
impl_ty
ty::Ty<'tcx>
output
&mut Vec<TransItem<'tcx>>