Skip to content

Commit 21fff2c

Browse files
committed
Auto merge of #88135 - crlf0710:trait_upcasting_part_3, r=nikomatsakis
Trait upcasting coercion (part 3) By using separate candidates for each possible choice, this fixes type-checking issues in previous commits. r? `@nikomatsakis`
2 parents 8b8ab5f + 03ed8c8 commit 21fff2c

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

src/unsize.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,10 @@ pub(crate) fn unsized_info<'tcx>(
3131
if data_a.principal_def_id() == data_b.principal_def_id() {
3232
return old_info;
3333
}
34-
// trait upcasting coercion
3534

36-
// if both of the two `principal`s are `None`, this function would have returned early above.
37-
// and if one of the two `principal`s is `None`, typechecking would have rejected this case.
38-
let principal_a = data_a
39-
.principal()
40-
.expect("unsized_info: missing principal trait for trait upcasting coercion");
41-
let principal_b = data_b
42-
.principal()
43-
.expect("unsized_info: missing principal trait for trait upcasting coercion");
44-
45-
let vptr_entry_idx = fx.tcx.vtable_trait_upcasting_coercion_new_vptr_slot((
46-
principal_a.with_self_ty(fx.tcx, source),
47-
principal_b.with_self_ty(fx.tcx, source),
48-
));
35+
// trait upcasting coercion
36+
let vptr_entry_idx =
37+
fx.tcx.vtable_trait_upcasting_coercion_new_vptr_slot((source, target));
4938

5039
if let Some(entry_idx) = vptr_entry_idx {
5140
let entry_idx = u32::try_from(entry_idx).unwrap();

0 commit comments

Comments
 (0)