@@ -96,24 +96,28 @@ fn dyn_trait_in_self(ty: Ty<'_>) -> Option<ty::PolyExistentialTraitRef<'_>> {
96
96
pub ( crate ) fn get_vtable < ' tcx , Cx : CodegenMethods < ' tcx > > (
97
97
cx : & Cx ,
98
98
ty : Ty < ' tcx > ,
99
- trait_ref : Option < ty:: PolyExistentialTraitRef < ' tcx > > ,
99
+ poly_trait_ref : Option < ty:: PolyExistentialTraitRef < ' tcx > > ,
100
100
) -> Cx :: Value {
101
101
let tcx = cx. tcx ( ) ;
102
102
103
103
// Check the cache.
104
- if let Some ( & val) = cx. vtables ( ) . borrow ( ) . get ( & ( ty, trait_ref ) ) {
104
+ if let Some ( & val) = cx. vtables ( ) . borrow ( ) . get ( & ( ty, poly_trait_ref ) ) {
105
105
return val;
106
106
}
107
107
108
+ // FIXME(trait_upcasting): Take a non-higher-ranked vtable as arg.
109
+ let trait_ref =
110
+ poly_trait_ref. map ( |trait_ref| tcx. instantiate_bound_regions_with_erased ( trait_ref) ) ;
111
+
108
112
let vtable_alloc_id = tcx. vtable_allocation ( ( ty, trait_ref) ) ;
109
113
let vtable_allocation = tcx. global_alloc ( vtable_alloc_id) . unwrap_memory ( ) ;
110
114
let vtable_const = cx. const_data_from_alloc ( vtable_allocation) ;
111
115
let align = cx. data_layout ( ) . pointer_align . abi ;
112
116
let vtable = cx. static_addr_of ( vtable_const, align, Some ( "vtable" ) ) ;
113
117
114
- cx. apply_vcall_visibility_metadata ( ty, trait_ref , vtable) ;
115
- cx. create_vtable_debuginfo ( ty, trait_ref , vtable) ;
116
- cx. vtables ( ) . borrow_mut ( ) . insert ( ( ty, trait_ref ) , vtable) ;
118
+ cx. apply_vcall_visibility_metadata ( ty, poly_trait_ref , vtable) ;
119
+ cx. create_vtable_debuginfo ( ty, poly_trait_ref , vtable) ;
120
+ cx. vtables ( ) . borrow_mut ( ) . insert ( ( ty, poly_trait_ref ) , vtable) ;
117
121
vtable
118
122
}
119
123
0 commit comments