Fold `vtable_trait_upcasting_coercion_new_vptr_slot` logic into obligation processing.

This commit is contained in:
Charles Lew 2021-08-18 12:45:18 +08:00
parent 1bfa59afe0
commit 03ed8c8115
1 changed files with 3 additions and 14 deletions

View File

@ -31,21 +31,10 @@ pub(crate) fn unsized_info<'tcx>(
if data_a.principal_def_id() == data_b.principal_def_id() { if data_a.principal_def_id() == data_b.principal_def_id() {
return old_info; return old_info;
} }
// trait upcasting coercion // trait upcasting coercion
let vptr_entry_idx =
// if both of the two `principal`s are `None`, this function would have returned early above. fx.tcx.vtable_trait_upcasting_coercion_new_vptr_slot((source, target));
// and if one of the two `principal`s is `None`, typechecking would have rejected this case.
let principal_a = data_a
.principal()
.expect("unsized_info: missing principal trait for trait upcasting coercion");
let principal_b = data_b
.principal()
.expect("unsized_info: missing principal trait for trait upcasting coercion");
let vptr_entry_idx = fx.tcx.vtable_trait_upcasting_coercion_new_vptr_slot((
principal_a.with_self_ty(fx.tcx, source),
principal_b.with_self_ty(fx.tcx, source),
));
if let Some(entry_idx) = vptr_entry_idx { if let Some(entry_idx) = vptr_entry_idx {
let entry_idx = u32::try_from(entry_idx).unwrap(); let entry_idx = u32::try_from(entry_idx).unwrap();