diff options
| author | bors <bors@rust-lang.org> | 2024-06-16 05:33:49 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-06-16 05:33:49 +0000 |
| commit | 5639c21fb38d26a72420fe627be25d4f6dfc1f3b (patch) | |
| tree | 33e2ca0475e235b516018f49f76b1f50fbe12c5f /compiler/rustc_middle/src/query/mod.rs | |
| parent | cd0c944b0750db887291bc25f20a05f8f31a8195 (diff) | |
| parent | 3b9adbec32757264ba30b68e04ce66d6023810aa (diff) | |
| download | rust-5639c21fb38d26a72420fe627be25d4f6dfc1f3b.tar.gz rust-5639c21fb38d26a72420fe627be25d4f6dfc1f3b.zip | |
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.
Diffstat (limited to 'compiler/rustc_middle/src/query/mod.rs')
| -rw-r--r-- | compiler/rustc_middle/src/query/mod.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index a8bf735fa5a..8ba930f493e 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -46,6 +46,7 @@ use crate::traits::{ }; use crate::ty::fast_reject::SimplifiedType; use crate::ty::layout::ValidityRequirement; +use crate::ty::print::PrintTraitRefExt; use crate::ty::util::AlwaysRequiresDrop; use crate::ty::TyCtxtFeed; use crate::ty::{ @@ -1271,7 +1272,11 @@ rustc_queries! { desc { |tcx| "finding all vtable entries for trait `{}`", tcx.def_path_str(key.def_id()) } } - query vtable_trait_upcasting_coercion_new_vptr_slot(key: (Ty<'tcx>, Ty<'tcx>)) -> Option<usize> { + query first_method_vtable_slot(key: ty::TraitRef<'tcx>) -> usize { + desc { |tcx| "finding the slot within the vtable of `{}` for the implementation of `{}`", key.self_ty(), key.print_only_trait_name() } + } + + query supertrait_vtable_slot(key: (Ty<'tcx>, Ty<'tcx>)) -> Option<usize> { desc { |tcx| "finding the slot within vtable for trait object `{}` vtable ptr during trait upcasting coercion from `{}` vtable", key.1, key.0 } } |
