diff options
| author | Michael Goulet <michael@errs.io> | 2022-11-02 00:38:43 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-11-02 00:39:08 +0000 |
| commit | 20bb56ebfd4a9d8b21de8f8e75e062ae48d04810 (patch) | |
| tree | 76608c23cc419ecfaed850baaef94359daf4e6ed | |
| parent | ab5a2bc7316012ee9b2a4a4f3821673f2677f3d5 (diff) | |
| download | rust-20bb56ebfd4a9d8b21de8f8e75e062ae48d04810.tar.gz rust-20bb56ebfd4a9d8b21de8f8e75e062ae48d04810.zip | |
Use codegen_select in vtable_trait_upcasting_coercion_new_vptr_slot
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/mod.rs | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 0bf54c096cd..4e764d70ba9 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -933,25 +933,13 @@ pub fn vtable_trait_upcasting_coercion_new_vptr_slot<'tcx>( def_id: unsize_trait_did, substs: tcx.mk_substs_trait(source, &[target.into()]), }; - let obligation = Obligation::new( - ObligationCause::dummy(), - ty::ParamEnv::reveal_all(), - ty::Binder::dummy(ty::TraitPredicate { - trait_ref, - constness: ty::BoundConstness::NotConst, - polarity: ty::ImplPolarity::Positive, - }), - ); - - let infcx = tcx.infer_ctxt().build(); - let mut selcx = SelectionContext::new(&infcx); - let implsrc = selcx.select(&obligation).unwrap(); - let Some(ImplSource::TraitUpcasting(implsrc_traitcasting)) = implsrc else { - bug!(); - }; - - implsrc_traitcasting.vtable_vptr_slot + match tcx.codegen_select_candidate((ty::ParamEnv::reveal_all(), ty::Binder::dummy(trait_ref))) { + Ok(ImplSource::TraitUpcasting(implsrc_traitcasting)) => { + implsrc_traitcasting.vtable_vptr_slot + } + otherwise => bug!("expected TraitUpcasting candidate, got {otherwise:?}"), + } } pub fn provide(providers: &mut ty::query::Providers) { |
