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_trait_selection/src/solve/assembly/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_trait_selection/src/solve/assembly/mod.rs')
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/assembly/mod.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/assembly/mod.rs b/compiler/rustc_trait_selection/src/solve/assembly/mod.rs index 72cdfb5e57b..1cdbf082078 100644 --- a/compiler/rustc_trait_selection/src/solve/assembly/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/assembly/mod.rs @@ -5,6 +5,7 @@ use rustc_hir::def_id::DefId; use rustc_hir::LangItem; use rustc_infer::infer::InferCtxt; use rustc_infer::traits::query::NoSolution; +use rustc_infer::traits::util::supertraits; use rustc_middle::bug; use rustc_middle::traits::solve::inspect::ProbeKind; use rustc_middle::traits::solve::{Certainty, Goal, MaybeCause, QueryResult}; @@ -744,14 +745,14 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> { // a projection goal. if let Some(principal) = bounds.principal() { let principal_trait_ref = principal.with_self_ty(tcx, self_ty); - self.walk_vtable(principal_trait_ref, |ecx, assumption, vtable_base, _| { + for (idx, assumption) in supertraits(self.interner(), principal_trait_ref).enumerate() { candidates.extend(G::probe_and_consider_object_bound_candidate( - ecx, - CandidateSource::BuiltinImpl(BuiltinImplSource::Object { vtable_base }), + self, + CandidateSource::BuiltinImpl(BuiltinImplSource::Object(idx)), goal, assumption.upcast(tcx), )); - }); + } } } |
