@@ -647,14 +647,14 @@ fn vtable_entries<'tcx>(
647647 . filter ( |item| item. kind == ty:: AssocKind :: Fn ) ;
648648 // Now list each method's DefId and InternalSubsts (for within its trait).
649649 // If the method can never be called from this object, produce `Vacant`.
650- let own_entries = trait_methods. map ( move |trait_method| {
650+ let own_entries = trait_methods. filter_map ( move |trait_method| {
651651 debug ! ( "vtable_entries: trait_method={:?}" , trait_method) ;
652652 let def_id = trait_method. def_id ;
653653
654654 // Some methods cannot be called on an object; skip those.
655655 if !is_vtable_safe_method ( tcx, trait_ref. def_id ( ) , & trait_method) {
656656 debug ! ( "vtable_entries: not vtable safe" ) ;
657- return VtblEntry :: Vacant ;
657+ return None ;
658658 }
659659
660660 // The method may have some early-bound lifetimes; add regions for those.
@@ -681,7 +681,7 @@ fn vtable_entries<'tcx>(
681681 let predicates = tcx. predicates_of ( def_id) . instantiate_own ( tcx, substs) ;
682682 if impossible_predicates ( tcx, predicates. predicates ) {
683683 debug ! ( "vtable_entries: predicates do not hold" ) ;
684- return VtblEntry :: Vacant ;
684+ return Some ( VtblEntry :: Vacant ) ;
685685 }
686686
687687 let instance = ty:: Instance :: resolve_for_vtable (
@@ -691,7 +691,7 @@ fn vtable_entries<'tcx>(
691691 substs,
692692 )
693693 . expect ( "resolution failed during building vtable representation" ) ;
694- VtblEntry :: Method ( instance)
694+ Some ( VtblEntry :: Method ( instance) )
695695 } ) ;
696696
697697 entries. extend ( own_entries) ;
0 commit comments