Skip to content

Commit 5c6849b

Browse files
committed
Auto merge of #126505 - compiler-errors:no-vtable, r=lcnr
Only compute vtable information during codegen This PR removes vtable information from the `Object` and `TraitUpcasting` candidate sources in the trait solvers, and defers the computation of relevant information to `Instance::resolve`. This is because vtables really aren't a thing in the trait world -- they're an implementation detail in codegen. Previously it was just easiest to tangle this information together since we were already doing the work of looking at all the supertraits in the trait solver, and specifically because we use traits to represent when it's possible to call a method via a vtable (`Object` candidate) and do upcasting (`Unsize` candidate). but I am somewhat suspicious we're doing a *lot* of extra work, especially in polymorphic contexts, so let's see what perf says.
2 parents c867677 + 5ccfa78 commit 5c6849b

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/unsize.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ pub(crate) fn unsized_info<'tcx>(
3939
}
4040

4141
// trait upcasting coercion
42-
let vptr_entry_idx =
43-
fx.tcx.vtable_trait_upcasting_coercion_new_vptr_slot((source, target));
42+
let vptr_entry_idx = fx.tcx.supertrait_vtable_slot((source, target));
4443

4544
if let Some(entry_idx) = vptr_entry_idx {
4645
let entry_idx = u32::try_from(entry_idx).unwrap();

0 commit comments

Comments
 (0)