@@ -30,16 +30,18 @@ pub enum VtblSegment<'tcx> {
30
30
pub fn prepare_vtable_segments < ' tcx , T > (
31
31
tcx : TyCtxt < ' tcx > ,
32
32
trait_ref : ty:: TraitRef < ' tcx > ,
33
+ typing_env : ty:: TypingEnv < ' tcx > ,
33
34
segment_visitor : impl FnMut ( VtblSegment < ' tcx > ) -> ControlFlow < T > ,
34
35
) -> 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 ( )
36
37
}
37
38
38
39
/// Helper for [`prepare_vtable_segments`] that returns `ControlFlow`,
39
40
/// such that we can use `?` in the body.
40
41
fn prepare_vtable_segments_inner < ' tcx , T > (
41
42
tcx : TyCtxt < ' tcx > ,
42
43
trait_ref : ty:: TraitRef < ' tcx > ,
44
+ typing_env : ty:: TypingEnv < ' tcx > ,
43
45
mut segment_visitor : impl FnMut ( VtblSegment < ' tcx > ) -> ControlFlow < T > ,
44
46
) -> ControlFlow < T > {
45
47
// The following constraints holds for the final arrangement.
@@ -129,7 +131,8 @@ fn prepare_vtable_segments_inner<'tcx, T>(
129
131
. iter_identity_copied ( )
130
132
. filter_map ( move |( pred, _) | {
131
133
Some (
132
- tcx. instantiate_bound_regions_with_erased (
134
+ tcx. normalize_erasing_late_bound_regions (
135
+ typing_env,
133
136
pred. instantiate_supertrait (
134
137
tcx,
135
138
ty:: Binder :: dummy ( inner_most_trait_ref) ,
@@ -306,7 +309,12 @@ fn vtable_entries<'tcx>(
306
309
ControlFlow :: Continue ( ( ) )
307
310
} ;
308
311
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
+ ) ;
310
318
311
319
if tcx. has_attr ( trait_ref. def_id , sym:: rustc_dump_vtable) {
312
320
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
358
366
}
359
367
} ;
360
368
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 ( )
362
376
}
363
377
364
378
/// Given a `dyn Subtrait` and `dyn Supertrait` trait object, find the slot of
@@ -420,7 +434,13 @@ pub(crate) fn supertrait_vtable_slot<'tcx>(
420
434
}
421
435
} ;
422
436
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 ( )
424
444
}
425
445
426
446
fn trait_refs_are_compatible < ' tcx > (
0 commit comments