@@ -647,14 +647,14 @@ fn vtable_entries<'tcx>(
647
647
. filter ( |item| item. kind == ty:: AssocKind :: Fn ) ;
648
648
// Now list each method's DefId and InternalSubsts (for within its trait).
649
649
// 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| {
651
651
debug ! ( "vtable_entries: trait_method={:?}" , trait_method) ;
652
652
let def_id = trait_method. def_id ;
653
653
654
654
// Some methods cannot be called on an object; skip those.
655
655
if !is_vtable_safe_method ( tcx, trait_ref. def_id ( ) , & trait_method) {
656
656
debug ! ( "vtable_entries: not vtable safe" ) ;
657
- return VtblEntry :: Vacant ;
657
+ return None ;
658
658
}
659
659
660
660
// The method may have some early-bound lifetimes; add regions for those.
@@ -681,7 +681,7 @@ fn vtable_entries<'tcx>(
681
681
let predicates = tcx. predicates_of ( def_id) . instantiate_own ( tcx, substs) ;
682
682
if impossible_predicates ( tcx, predicates. predicates ) {
683
683
debug ! ( "vtable_entries: predicates do not hold" ) ;
684
- return VtblEntry :: Vacant ;
684
+ return Some ( VtblEntry :: Vacant ) ;
685
685
}
686
686
687
687
let instance = ty:: Instance :: resolve_for_vtable (
@@ -691,7 +691,7 @@ fn vtable_entries<'tcx>(
691
691
substs,
692
692
)
693
693
. expect ( "resolution failed during building vtable representation" ) ;
694
- VtblEntry :: Method ( instance)
694
+ Some ( VtblEntry :: Method ( instance) )
695
695
} ) ;
696
696
697
697
entries. extend ( own_entries) ;
0 commit comments