about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-08-21 21:14:07 +0000
committerbors <bors@rust-lang.org>2021-08-21 21:14:07 +0000
commit21fff2c6c3f3b2986865a1368b1c5e76a20e5f12 (patch)
tree8fcb48d3721a93cccc14807049afa2853aa5fee0
parent8b8ab5f599f04d83f31994a47cf2345dbaddd38b (diff)
parent03ed8c811513a41ad076ae206cbc2a930888bef2 (diff)
downloadrust-21fff2c6c3f3b2986865a1368b1c5e76a20e5f12.tar.gz
rust-21fff2c6c3f3b2986865a1368b1c5e76a20e5f12.zip
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`
-rw-r--r--src/unsize.rs17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/unsize.rs b/src/unsize.rs
index d9c4647cba3..fd96858010e 100644
--- a/src/unsize.rs
+++ b/src/unsize.rs
@@ -31,21 +31,10 @@ pub(crate) fn unsized_info<'tcx>(
             if data_a.principal_def_id() == data_b.principal_def_id() {
                 return old_info;
             }
-            // trait upcasting coercion
 
-            // if both of the two `principal`s are `None`, this function would have returned early above.
-            // 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),
-            ));
+            // trait upcasting coercion
+            let vptr_entry_idx =
+                fx.tcx.vtable_trait_upcasting_coercion_new_vptr_slot((source, target));
 
             if let Some(entry_idx) = vptr_entry_idx {
                 let entry_idx = u32::try_from(entry_idx).unwrap();