@@ -1034,14 +1034,12 @@ fn create_mono_items_for_vtable_methods<'a, 'tcx>(
1034
1034
let drop_glue_instance = visit_drop_use ( tcx, impl_ty, false , output) ;
1035
1035
1036
1036
if let Some ( principal) = trait_sty. principal ( ) {
1037
- let drop_glue = drop_glue. entry ( drop_glue_instance) . or_default ( ) ;
1038
-
1039
- // the principal trait may not have any method but we must consider it in drop glue call
1040
- // metadata
1041
- drop_glue. insert ( tcx. normalize_erasing_late_bound_regions (
1042
- ty:: ParamEnv :: reveal_all ( ) ,
1043
- & principal,
1044
- ) ) ;
1037
+ // we only consider the principal trait for the drop glue call metadata
1038
+ drop_glue. entry ( drop_glue_instance) . or_default ( ) . insert (
1039
+ tcx. normalize_erasing_late_bound_regions (
1040
+ ty:: ParamEnv :: reveal_all ( ) ,
1041
+ & principal,
1042
+ ) ) ;
1045
1043
1046
1044
let poly_trait_ref = principal. with_self_ty ( tcx, impl_ty) ;
1047
1045
assert ! ( !poly_trait_ref. has_escaping_bound_vars( ) ) ;
@@ -1064,8 +1062,7 @@ fn create_mono_items_for_vtable_methods<'a, 'tcx>(
1064
1062
. filter ( |instance| should_monomorphize_locally ( tcx, & instance) ) ;
1065
1063
1066
1064
for instance in methods {
1067
- if let Some ( ( trait_ref, _) ) = instance. trait_ref_and_method ( tcx) {
1068
- drop_glue. insert ( trait_ref) ;
1065
+ if instance. trait_ref_and_method ( tcx) . is_some ( ) {
1069
1066
dynamic_dispatch. insert ( instance) ;
1070
1067
}
1071
1068
@@ -1354,10 +1351,9 @@ fn collect_miri<'a, 'tcx>(
1354
1351
}
1355
1352
} ) . next ( ) ;
1356
1353
1357
- if let Some ( drop_glue_instance) = drop_glue_instance {
1358
- // FIXME(japaric) if the principal trait happens to have no methods the `for` loop
1359
- // below won't insert it into `drop_glue`; we must include it separately here
1360
- let drop_glue = drop_glue. entry ( drop_glue_instance) . or_default ( ) ;
1354
+ if let Some ( _drop_glue_instance) = drop_glue_instance {
1355
+ // FIXME(japaric) we need to insert only the principal trait into `drop_glue`
1356
+ // drop_glue.entry(drop_glue_instance).or_default().insert(???);
1361
1357
1362
1358
// trait object in const / static context
1363
1359
for ( ( ) , inner) in alloc. relocations . values ( ) {
@@ -1367,9 +1363,8 @@ fn collect_miri<'a, 'tcx>(
1367
1363
if should_monomorphize_locally ( tcx, & instance) {
1368
1364
trace ! ( "collecting {:?} with {:#?}" , alloc_id, instance) ;
1369
1365
1370
- if let Some ( ( trait_ref , _ ) ) = instance. trait_ref_and_method ( tcx) {
1366
+ if instance. trait_ref_and_method ( tcx) . is_some ( ) {
1371
1367
dynamic_dispatch. insert ( instance) ;
1372
- drop_glue. insert ( trait_ref) ;
1373
1368
}
1374
1369
1375
1370
output. push ( create_fn_mono_item ( instance) ) ;
0 commit comments