@@ -96,24 +96,28 @@ fn dyn_trait_in_self(ty: Ty<'_>) -> Option<ty::PolyExistentialTraitRef<'_>> {
9696pub ( crate ) fn get_vtable < ' tcx , Cx : CodegenMethods < ' tcx > > (
9797 cx : & Cx ,
9898 ty : Ty < ' tcx > ,
99- trait_ref : Option < ty:: PolyExistentialTraitRef < ' tcx > > ,
99+ poly_trait_ref : Option < ty:: PolyExistentialTraitRef < ' tcx > > ,
100100) -> Cx :: Value {
101101 let tcx = cx. tcx ( ) ;
102102
103103 // 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 ) ) {
105105 return val;
106106 }
107107
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+
108112 let vtable_alloc_id = tcx. vtable_allocation ( ( ty, trait_ref) ) ;
109113 let vtable_allocation = tcx. global_alloc ( vtable_alloc_id) . unwrap_memory ( ) ;
110114 let vtable_const = cx. const_data_from_alloc ( vtable_allocation) ;
111115 let align = cx. data_layout ( ) . pointer_align . abi ;
112116 let vtable = cx. static_addr_of ( vtable_const, align, Some ( "vtable" ) ) ;
113117
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) ;
117121 vtable
118122}
119123
0 commit comments