File tree 1 file changed +6
-18
lines changed
compiler/rustc_trait_selection/src/traits
1 file changed +6
-18
lines changed Original file line number Diff line number Diff line change @@ -900,25 +900,13 @@ pub fn vtable_trait_upcasting_coercion_new_vptr_slot<'tcx>(
900
900
def_id : unsize_trait_did,
901
901
substs : tcx. mk_substs_trait ( source, & [ target. into ( ) ] ) ,
902
902
} ;
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 ( ) ;
916
903
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
+ }
922
910
}
923
911
924
912
pub fn provide ( providers : & mut ty:: query:: Providers ) {
You can’t perform that action at this time.
0 commit comments