@@ -887,9 +887,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
887
887
let ty:: Dynamic ( b_data, b_region, ty:: Dyn ) = * b_ty. kind ( ) else { bug ! ( ) } ;
888
888
889
889
let source_principal = a_data. principal ( ) . unwrap ( ) . with_self_ty ( tcx, a_ty) ;
890
- let upcast_principal = util:: supertraits ( tcx, source_principal) . nth ( idx) . unwrap ( ) ;
890
+ let unnormalized_upcast_principal =
891
+ util:: supertraits ( tcx, source_principal) . nth ( idx) . unwrap ( ) ;
891
892
892
893
let mut nested = vec ! [ ] ;
894
+ let upcast_principal = normalize_with_depth_to (
895
+ self ,
896
+ obligation. param_env ,
897
+ obligation. cause . clone ( ) ,
898
+ obligation. recursion_depth + 1 ,
899
+ unnormalized_upcast_principal,
900
+ & mut nested,
901
+ ) ;
902
+
893
903
for bound in b_data {
894
904
match bound. skip_binder ( ) {
895
905
// Check that a's supertrait (upcast_principal) is compatible
@@ -973,7 +983,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
973
983
}
974
984
VtblSegment :: TraitOwnEntries { trait_ref, emit_vptr } => {
975
985
vptr_offset += count_own_vtable_entries ( tcx, trait_ref) ;
976
- if trait_ref == upcast_principal {
986
+ if trait_ref == unnormalized_upcast_principal {
977
987
if emit_vptr {
978
988
return ControlFlow :: Break ( Some ( vptr_offset) ) ;
979
989
} else {
0 commit comments