@@ -27,7 +27,8 @@ use rustc_session::config::{self, CrateType, EntryFnType, OptLevel, OutputType};
2727use rustc_span:: symbol:: sym;
2828use rustc_span:: { DUMMY_SP , Symbol } ;
2929use rustc_target:: abi:: FIRST_VARIANT ;
30- use rustc_trait_selection:: infer:: TyCtxtInferExt ;
30+ use rustc_trait_selection:: infer:: at:: ToTrace ;
31+ use rustc_trait_selection:: infer:: { BoundRegionConversionTime , TyCtxtInferExt } ;
3132use rustc_trait_selection:: traits:: { ObligationCause , ObligationCtxt } ;
3233use tracing:: { debug, info} ;
3334
@@ -113,22 +114,38 @@ pub fn compare_simd_types<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
113114/// unsound, so let's validate here that the trait refs are subtypes.
114115pub fn validate_trivial_unsize < ' tcx > (
115116 tcx : TyCtxt < ' tcx > ,
116- data_a : & ' tcx ty:: List < ty:: PolyExistentialPredicate < ' tcx > > ,
117- data_b : & ' tcx ty:: List < ty:: PolyExistentialPredicate < ' tcx > > ,
117+ source_data : & ' tcx ty:: List < ty:: PolyExistentialPredicate < ' tcx > > ,
118+ target_data : & ' tcx ty:: List < ty:: PolyExistentialPredicate < ' tcx > > ,
118119) -> bool {
119- match ( data_a . principal ( ) , data_b . principal ( ) ) {
120- ( Some ( principal_a ) , Some ( principal_b ) ) => {
120+ match ( source_data . principal ( ) , target_data . principal ( ) ) {
121+ ( Some ( hr_source_principal ) , Some ( hr_target_principal ) ) => {
121122 let infcx = tcx. infer_ctxt ( ) . build ( ) ;
123+ let universe = infcx. universe ( ) ;
122124 let ocx = ObligationCtxt :: new ( & infcx) ;
123- let Ok ( ( ) ) = ocx. sub (
124- & ObligationCause :: dummy ( ) ,
125- ty:: ParamEnv :: reveal_all ( ) ,
126- principal_a,
127- principal_b,
128- ) else {
129- return false ;
130- } ;
131- ocx. select_all_or_error ( ) . is_empty ( )
125+ infcx. enter_forall ( hr_target_principal, |target_principal| {
126+ let source_principal = infcx. instantiate_binder_with_fresh_vars (
127+ DUMMY_SP ,
128+ BoundRegionConversionTime :: HigherRankedType ,
129+ hr_source_principal,
130+ ) ;
131+ let Ok ( ( ) ) = ocx. eq_trace (
132+ & ObligationCause :: dummy ( ) ,
133+ ty:: ParamEnv :: reveal_all ( ) ,
134+ ToTrace :: to_trace (
135+ & ObligationCause :: dummy ( ) ,
136+ hr_target_principal,
137+ hr_source_principal,
138+ ) ,
139+ target_principal,
140+ source_principal,
141+ ) else {
142+ return false ;
143+ } ;
144+ if !ocx. select_all_or_error ( ) . is_empty ( ) {
145+ return false ;
146+ }
147+ infcx. leak_check ( universe, None ) . is_ok ( )
148+ } )
132149 }
133150 ( None , None ) => true ,
134151 _ => false ,
0 commit comments