@@ -30,16 +30,18 @@ pub enum VtblSegment<'tcx> {
3030pub fn prepare_vtable_segments < ' tcx , T > (
3131 tcx : TyCtxt < ' tcx > ,
3232 trait_ref : ty:: TraitRef < ' tcx > ,
33+ typing_env : ty:: TypingEnv < ' tcx > ,
3334 segment_visitor : impl FnMut ( VtblSegment < ' tcx > ) -> ControlFlow < T > ,
3435) -> Option < T > {
35- prepare_vtable_segments_inner ( tcx, trait_ref, segment_visitor) . break_value ( )
36+ prepare_vtable_segments_inner ( tcx, trait_ref, typing_env , segment_visitor) . break_value ( )
3637}
3738
3839/// Helper for [`prepare_vtable_segments`] that returns `ControlFlow`,
3940/// such that we can use `?` in the body.
4041fn prepare_vtable_segments_inner < ' tcx , T > (
4142 tcx : TyCtxt < ' tcx > ,
4243 trait_ref : ty:: TraitRef < ' tcx > ,
44+ typing_env : ty:: TypingEnv < ' tcx > ,
4345 mut segment_visitor : impl FnMut ( VtblSegment < ' tcx > ) -> ControlFlow < T > ,
4446) -> ControlFlow < T > {
4547 // The following constraints holds for the final arrangement.
@@ -129,7 +131,8 @@ fn prepare_vtable_segments_inner<'tcx, T>(
129131 . iter_identity_copied ( )
130132 . filter_map ( move |( pred, _) | {
131133 Some (
132- tcx. instantiate_bound_regions_with_erased (
134+ tcx. normalize_erasing_late_bound_regions (
135+ typing_env,
133136 pred. instantiate_supertrait (
134137 tcx,
135138 ty:: Binder :: dummy ( inner_most_trait_ref) ,
@@ -306,7 +309,12 @@ fn vtable_entries<'tcx>(
306309 ControlFlow :: Continue ( ( ) )
307310 } ;
308311
309- let _ = prepare_vtable_segments ( tcx, trait_ref, vtable_segment_callback) ;
312+ let _ = prepare_vtable_segments (
313+ tcx,
314+ trait_ref,
315+ ty:: TypingEnv :: fully_monomorphized ( ) ,
316+ vtable_segment_callback,
317+ ) ;
310318
311319 if tcx. has_attr ( trait_ref. def_id , sym:: rustc_dump_vtable) {
312320 let sp = tcx. def_span ( trait_ref. def_id ) ;
@@ -358,7 +366,13 @@ pub(crate) fn first_method_vtable_slot<'tcx>(tcx: TyCtxt<'tcx>, key: ty::TraitRe
358366 }
359367 } ;
360368
361- prepare_vtable_segments ( tcx, source_principal, vtable_segment_callback) . unwrap ( )
369+ prepare_vtable_segments (
370+ tcx,
371+ source_principal,
372+ ty:: TypingEnv :: fully_monomorphized ( ) ,
373+ vtable_segment_callback,
374+ )
375+ . unwrap ( )
362376}
363377
364378/// Given a `dyn Subtrait` and `dyn Supertrait` trait object, find the slot of
@@ -420,7 +434,13 @@ pub(crate) fn supertrait_vtable_slot<'tcx>(
420434 }
421435 } ;
422436
423- prepare_vtable_segments ( tcx, source_principal, vtable_segment_callback) . unwrap ( )
437+ prepare_vtable_segments (
438+ tcx,
439+ source_principal,
440+ ty:: TypingEnv :: fully_monomorphized ( ) ,
441+ vtable_segment_callback,
442+ )
443+ . unwrap ( )
424444}
425445
426446fn trait_refs_are_compatible < ' tcx > (
0 commit comments