@@ -66,8 +66,8 @@ pub use self::util::{
66
66
get_vtable_index_of_object_method, impl_item_is_final, predicate_for_trait_def, upcast_choices,
67
67
} ;
68
68
pub use self :: util:: {
69
- supertraits, supertraits_with_repetitions, supertrait_def_ids , transitive_bounds, Supertraits ,
70
- SupertraitDefIds ,
69
+ supertrait_def_ids , supertraits, supertraits_with_repetitions, transitive_bounds,
70
+ SupertraitDefIds , Supertraits ,
71
71
} ;
72
72
73
73
pub use rustc_infer:: traits:: * ;
@@ -472,52 +472,51 @@ fn vtable_methods<'tcx>(
472
472
) -> & ' tcx [ & ' tcx [ Option < ( DefId , SubstsRef < ' tcx > ) > ] ] {
473
473
debug ! ( "vtable_methods({:?})" , trait_ref) ;
474
474
475
- tcx. arena . alloc_from_iter ( supertraits_with_repetitions ( tcx, trait_ref)
476
- . map ( move |trait_ref| {
477
- let trait_methods = tcx
478
- . associated_items ( trait_ref. def_id ( ) )
479
- . in_definition_order ( )
480
- . filter ( |item| item. kind == ty:: AssocKind :: Fn ) ;
481
-
482
- // Now, list each method's `DefId` and `InternalSubsts` (for within its trait).
483
- // If the method can never be called from this object, produce `None`.
484
- & * tcx. arena . alloc_from_iter ( trait_methods. map ( move |trait_method| {
485
- debug ! ( "vtable_methods: trait_method={:?}" , trait_method) ;
486
- let def_id = trait_method. def_id ;
487
-
488
- // Some methods cannot be called on an object; skip those.
489
- if !is_vtable_safe_method ( tcx, trait_ref. def_id ( ) , & trait_method) {
490
- debug ! ( "vtable_methods: not vtable safe" ) ;
491
- return None ;
492
- }
475
+ tcx. arena . alloc_from_iter ( supertraits_with_repetitions ( tcx, trait_ref) . map ( move |trait_ref| {
476
+ let trait_methods = tcx
477
+ . associated_items ( trait_ref. def_id ( ) )
478
+ . in_definition_order ( )
479
+ . filter ( |item| item. kind == ty:: AssocKind :: Fn ) ;
480
+
481
+ // Now, list each method's `DefId` and `InternalSubsts` (for within its trait).
482
+ // If the method can never be called from this object, produce `None`.
483
+ & * tcx. arena . alloc_from_iter ( trait_methods. map ( move |trait_method| {
484
+ debug ! ( "vtable_methods: trait_method={:?}" , trait_method) ;
485
+ let def_id = trait_method. def_id ;
486
+
487
+ // Some methods cannot be called on an object; skip those.
488
+ if !is_vtable_safe_method ( tcx, trait_ref. def_id ( ) , & trait_method) {
489
+ debug ! ( "vtable_methods: not vtable safe" ) ;
490
+ return None ;
491
+ }
493
492
494
- // The method may have some early-bound lifetimes; add regions for those.
495
- let substs = trait_ref. map_bound ( |trait_ref| {
496
- InternalSubsts :: for_item ( tcx, def_id, |param, _| match param. kind {
497
- GenericParamDefKind :: Lifetime => tcx. lifetimes . re_erased . into ( ) ,
498
- GenericParamDefKind :: Type { .. } | GenericParamDefKind :: Const => {
499
- trait_ref. substs [ param. index as usize ]
500
- }
501
- } )
502
- } ) ;
503
-
504
- // The trait type may have higher-ranked lifetimes in it;
505
- // erase them if they appear, so that we get the type
506
- // at some particular call site.
507
- let substs =
508
- tcx. normalize_erasing_late_bound_regions ( ty:: ParamEnv :: reveal_all ( ) , & substs) ;
509
-
510
- // It's possible that the method relies on where-clauses that
511
- // do not hold for this particular set of type parameters.
512
- // Note that this method could then never be called, so we
513
- // do not want to try and codegen it, in that case (see #23435).
514
- let predicates = tcx. predicates_of ( def_id) . instantiate_own ( tcx, substs) ;
515
- if !normalize_and_test_predicates ( tcx, predicates. predicates ) {
516
- debug ! ( "vtable_methods: predicates do not hold" ) ;
517
- return None ;
518
- }
493
+ // The method may have some early-bound lifetimes; add regions for those.
494
+ let substs = trait_ref. map_bound ( |trait_ref| {
495
+ InternalSubsts :: for_item ( tcx, def_id, |param, _| match param. kind {
496
+ GenericParamDefKind :: Lifetime => tcx. lifetimes . re_erased . into ( ) ,
497
+ GenericParamDefKind :: Type { .. } | GenericParamDefKind :: Const => {
498
+ trait_ref. substs [ param. index as usize ]
499
+ }
500
+ } )
501
+ } ) ;
502
+
503
+ // The trait type may have higher-ranked lifetimes in it;
504
+ // erase them if they appear, so that we get the type
505
+ // at some particular call site.
506
+ let substs =
507
+ tcx. normalize_erasing_late_bound_regions ( ty:: ParamEnv :: reveal_all ( ) , & substs) ;
508
+
509
+ // It's possible that the method relies on where-clauses that
510
+ // do not hold for this particular set of type parameters.
511
+ // Note that this method could then never be called, so we
512
+ // do not want to try and codegen it, in that case (see #23435).
513
+ let predicates = tcx. predicates_of ( def_id) . instantiate_own ( tcx, substs) ;
514
+ if !normalize_and_test_predicates ( tcx, predicates. predicates ) {
515
+ debug ! ( "vtable_methods: predicates do not hold" ) ;
516
+ return None ;
517
+ }
519
518
520
- Some ( ( def_id, substs) )
519
+ Some ( ( def_id, substs) )
521
520
} ) )
522
521
} ) )
523
522
}
0 commit comments