Skip to content

Commit 1e1e5b8

Browse files
committed
Auto merge of #103861 - compiler-errors:codegen-select-in-vtable-slot, r=nagisa
Use `codegen_select` in `vtable_trait_upcasting_coercion_new_vptr_slot` A super tiny clean up
2 parents 534ddc6 + 20bb56e commit 1e1e5b8

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
@@ -900,25 +900,13 @@ pub fn vtable_trait_upcasting_coercion_new_vptr_slot<'tcx>(
900900
def_id: unsize_trait_did,
901901
substs: tcx.mk_substs_trait(source, &[target.into()]),
902902
};
903-
let obligation = Obligation::new(
904-
ObligationCause::dummy(),
905-
ty::ParamEnv::reveal_all(),
906-
ty::Binder::dummy(ty::TraitPredicate {
907-
trait_ref,
908-
constness: ty::BoundConstness::NotConst,
909-
polarity: ty::ImplPolarity::Positive,
910-
}),
911-
);
912-
913-
let infcx = tcx.infer_ctxt().build();
914-
let mut selcx = SelectionContext::new(&infcx);
915-
let implsrc = selcx.select(&obligation).unwrap();
916903

917-
let Some(ImplSource::TraitUpcasting(implsrc_traitcasting)) = implsrc else {
918-
bug!();
919-
};
920-
921-
implsrc_traitcasting.vtable_vptr_slot
904+
match tcx.codegen_select_candidate((ty::ParamEnv::reveal_all(), ty::Binder::dummy(trait_ref))) {
905+
Ok(ImplSource::TraitUpcasting(implsrc_traitcasting)) => {
906+
implsrc_traitcasting.vtable_vptr_slot
907+
}
908+
otherwise => bug!("expected TraitUpcasting candidate, got {otherwise:?}"),
909+
}
922910
}
923911

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

0 commit comments

Comments
 (0)