@@ -324,20 +324,25 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
324
324
traits:: ObligationCause :: misc ( span, self . body_id )
325
325
}
326
326
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 > )
328
335
-> infer:: UnitResult < ' tcx >
329
336
{
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) )
333
339
}
334
340
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 > )
336
342
-> infer:: UnitResult < ' tcx >
337
343
{
338
344
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) )
341
346
}
342
347
343
348
fn tcx ( & self ) -> TyCtxt < ' a , ' gcx , ' tcx > {
@@ -352,7 +357,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
352
357
let lv_ty = lv. ty ( mir, tcx) . to_ty ( tcx) ;
353
358
let rv_ty = rv. ty ( mir, tcx) ;
354
359
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) {
356
361
span_mirbug ! ( self , stmt, "bad assignment ({:?} = {:?}): {:?}" ,
357
362
lv_ty, rv_ty, terr) ;
358
363
}
@@ -413,7 +418,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
413
418
} => {
414
419
let lv_ty = location. ty ( mir, tcx) . to_ty ( tcx) ;
415
420
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) {
417
422
span_mirbug ! ( self , term, "bad DropAndReplace ({:?} = {:?}): {:?}" ,
418
423
lv_ty, rv_ty, terr) ;
419
424
}
@@ -430,7 +435,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
430
435
}
431
436
TerminatorKind :: SwitchInt { ref discr, switch_ty, .. } => {
432
437
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) {
434
439
span_mirbug ! ( self , term, "bad SwitchInt ({:?} on {:?}): {:?}" ,
435
440
switch_ty, discr_ty, terr) ;
436
441
}
@@ -492,7 +497,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
492
497
}
493
498
}
494
499
495
- fn check_call_dest ( & self ,
500
+ fn check_call_dest ( & mut self ,
496
501
mir : & Mir < ' tcx > ,
497
502
term : & Terminator < ' tcx > ,
498
503
sig : & ty:: FnSig < ' tcx > ,
@@ -501,7 +506,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
501
506
match * destination {
502
507
Some ( ( ref dest, _) ) => {
503
508
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) {
505
510
span_mirbug ! ( self , term,
506
511
"call dest mismatch ({:?} <- {:?}): {:?}" ,
507
512
dest_ty, sig. output, terr) ;
@@ -516,7 +521,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
516
521
}
517
522
}
518
523
519
- fn check_call_inputs ( & self ,
524
+ fn check_call_inputs ( & mut self ,
520
525
mir : & Mir < ' tcx > ,
521
526
term : & Terminator < ' tcx > ,
522
527
sig : & ty:: FnSig < ' tcx > ,
@@ -529,7 +534,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
529
534
}
530
535
for ( n, ( fn_arg, op_arg) ) in sig. inputs . iter ( ) . zip ( args) . enumerate ( ) {
531
536
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) {
533
538
span_mirbug ! ( self , term, "bad arg #{:?} ({:?} <- {:?}): {:?}" ,
534
539
n, fn_arg, op_arg_ty, terr) ;
535
540
}
@@ -547,7 +552,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
547
552
}
548
553
}
549
554
550
- fn check_box_free_inputs ( & self ,
555
+ fn check_box_free_inputs ( & mut self ,
551
556
mir : & Mir < ' tcx > ,
552
557
term : & Terminator < ' tcx > ,
553
558
sig : & ty:: FnSig < ' tcx > ,
@@ -584,7 +589,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
584
589
}
585
590
} ;
586
591
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) {
588
593
span_mirbug ! ( self , term, "bad box_free arg ({:?} <- {:?}): {:?}" ,
589
594
pointee_ty, arg_ty, terr) ;
590
595
}
0 commit comments