@@ -324,20 +324,25 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
324324 traits:: ObligationCause :: misc ( span, self . body_id )
325325 }
326326
327- fn sub_types ( & self , span : Span , sup : Ty < ' tcx > , sub : Ty < ' tcx > )
327+ pub fn register_infer_ok_obligations < T > ( & mut self , infer_ok : InferOk < ' tcx , T > ) -> T {
328+ for obligation in infer_ok. obligations {
329+ self . fulfillment_cx . register_predicate_obligation ( self . infcx , obligation) ;
330+ }
331+ infer_ok. value
332+ }
333+
334+ fn sub_types ( & mut self , sup : Ty < ' tcx > , sub : Ty < ' tcx > )
328335 -> infer:: UnitResult < ' tcx >
329336 {
330- self . infcx . sub_types ( false , & self . misc ( span) , sup, sub)
331- // FIXME(#32730) propagate obligations
332- . map ( |InferOk { obligations, .. } | assert ! ( obligations. is_empty( ) ) )
337+ self . infcx . sub_types ( false , & self . misc ( self . last_span ) , sup, sub)
338+ . map ( |ok| self . register_infer_ok_obligations ( ok) )
333339 }
334340
335- fn eq_types ( & self , span : Span , a : Ty < ' tcx > , b : Ty < ' tcx > )
341+ fn eq_types ( & mut self , span : Span , a : Ty < ' tcx > , b : Ty < ' tcx > )
336342 -> infer:: UnitResult < ' tcx >
337343 {
338344 self . infcx . eq_types ( false , & self . misc ( span) , a, b)
339- // FIXME(#32730) propagate obligations
340- . map ( |InferOk { obligations, .. } | assert ! ( obligations. is_empty( ) ) )
345+ . map ( |ok| self . register_infer_ok_obligations ( ok) )
341346 }
342347
343348 fn tcx ( & self ) -> TyCtxt < ' a , ' gcx , ' tcx > {
@@ -352,7 +357,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
352357 let lv_ty = lv. ty ( mir, tcx) . to_ty ( tcx) ;
353358 let rv_ty = rv. ty ( mir, tcx) ;
354359 if let Some ( rv_ty) = rv_ty {
355- if let Err ( terr) = self . sub_types ( self . last_span , rv_ty, lv_ty) {
360+ if let Err ( terr) = self . sub_types ( rv_ty, lv_ty) {
356361 span_mirbug ! ( self , stmt, "bad assignment ({:?} = {:?}): {:?}" ,
357362 lv_ty, rv_ty, terr) ;
358363 }
@@ -413,7 +418,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
413418 } => {
414419 let lv_ty = location. ty ( mir, tcx) . to_ty ( tcx) ;
415420 let rv_ty = value. ty ( mir, tcx) ;
416- if let Err ( terr) = self . sub_types ( self . last_span , rv_ty, lv_ty) {
421+ if let Err ( terr) = self . sub_types ( rv_ty, lv_ty) {
417422 span_mirbug ! ( self , term, "bad DropAndReplace ({:?} = {:?}): {:?}" ,
418423 lv_ty, rv_ty, terr) ;
419424 }
@@ -430,7 +435,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
430435 }
431436 TerminatorKind :: SwitchInt { ref discr, switch_ty, .. } => {
432437 let discr_ty = discr. ty ( mir, tcx) . to_ty ( tcx) ;
433- if let Err ( terr) = self . sub_types ( self . last_span , discr_ty, switch_ty) {
438+ if let Err ( terr) = self . sub_types ( discr_ty, switch_ty) {
434439 span_mirbug ! ( self , term, "bad SwitchInt ({:?} on {:?}): {:?}" ,
435440 switch_ty, discr_ty, terr) ;
436441 }
@@ -492,7 +497,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
492497 }
493498 }
494499
495- fn check_call_dest ( & self ,
500+ fn check_call_dest ( & mut self ,
496501 mir : & Mir < ' tcx > ,
497502 term : & Terminator < ' tcx > ,
498503 sig : & ty:: FnSig < ' tcx > ,
@@ -501,7 +506,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
501506 match * destination {
502507 Some ( ( ref dest, _) ) => {
503508 let dest_ty = dest. ty ( mir, tcx) . to_ty ( tcx) ;
504- if let Err ( terr) = self . sub_types ( self . last_span , sig. output , dest_ty) {
509+ if let Err ( terr) = self . sub_types ( sig. output , dest_ty) {
505510 span_mirbug ! ( self , term,
506511 "call dest mismatch ({:?} <- {:?}): {:?}" ,
507512 dest_ty, sig. output, terr) ;
@@ -516,7 +521,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
516521 }
517522 }
518523
519- fn check_call_inputs ( & self ,
524+ fn check_call_inputs ( & mut self ,
520525 mir : & Mir < ' tcx > ,
521526 term : & Terminator < ' tcx > ,
522527 sig : & ty:: FnSig < ' tcx > ,
@@ -529,7 +534,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
529534 }
530535 for ( n, ( fn_arg, op_arg) ) in sig. inputs . iter ( ) . zip ( args) . enumerate ( ) {
531536 let op_arg_ty = op_arg. ty ( mir, self . tcx ( ) ) ;
532- if let Err ( terr) = self . sub_types ( self . last_span , op_arg_ty, fn_arg) {
537+ if let Err ( terr) = self . sub_types ( op_arg_ty, fn_arg) {
533538 span_mirbug ! ( self , term, "bad arg #{:?} ({:?} <- {:?}): {:?}" ,
534539 n, fn_arg, op_arg_ty, terr) ;
535540 }
@@ -547,7 +552,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
547552 }
548553 }
549554
550- fn check_box_free_inputs ( & self ,
555+ fn check_box_free_inputs ( & mut self ,
551556 mir : & Mir < ' tcx > ,
552557 term : & Terminator < ' tcx > ,
553558 sig : & ty:: FnSig < ' tcx > ,
@@ -584,7 +589,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
584589 }
585590 } ;
586591
587- if let Err ( terr) = self . sub_types ( self . last_span , arg_ty, pointee_ty) {
592+ if let Err ( terr) = self . sub_types ( arg_ty, pointee_ty) {
588593 span_mirbug ! ( self , term, "bad box_free arg ({:?} <- {:?}): {:?}" ,
589594 pointee_ty, arg_ty, terr) ;
590595 }
0 commit comments