Skip to content

Commit 20bb56e

Browse files
Use codegen_select in vtable_trait_upcasting_coercion_new_vptr_slot
1 parent ab5a2bc commit 20bb56e

File tree

1 file changed

+6
-18
lines changed
  • compiler/rustc_trait_selection/src/traits

1 file changed

+6
-18
lines changed

compiler/rustc_trait_selection/src/traits/mod.rs

+6-18
Original file line numberDiff line numberDiff line change
@@ -933,25 +933,13 @@ pub fn vtable_trait_upcasting_coercion_new_vptr_slot<'tcx>(
933933
def_id: unsize_trait_did,
934934
substs: tcx.mk_substs_trait(source, &[target.into()]),
935935
};
936-
let obligation = Obligation::new(
937-
ObligationCause::dummy(),
938-
ty::ParamEnv::reveal_all(),
939-
ty::Binder::dummy(ty::TraitPredicate {
940-
trait_ref,
941-
constness: ty::BoundConstness::NotConst,
942-
polarity: ty::ImplPolarity::Positive,
943-
}),
944-
);
945-
946-
let infcx = tcx.infer_ctxt().build();
947-
let mut selcx = SelectionContext::new(&infcx);
948-
let implsrc = selcx.select(&obligation).unwrap();
949936

950-
let Some(ImplSource::TraitUpcasting(implsrc_traitcasting)) = implsrc else {
951-
bug!();
952-
};
953-
954-
implsrc_traitcasting.vtable_vptr_slot
937+
match tcx.codegen_select_candidate((ty::ParamEnv::reveal_all(), ty::Binder::dummy(trait_ref))) {
938+
Ok(ImplSource::TraitUpcasting(implsrc_traitcasting)) => {
939+
implsrc_traitcasting.vtable_vptr_slot
940+
}
941+
otherwise => bug!("expected TraitUpcasting candidate, got {otherwise:?}"),
942+
}
955943
}
956944

957945
pub fn provide(providers: &mut ty::query::Providers) {

0 commit comments

Comments
 (0)