@@ -670,6 +670,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
670
670
self . drain_fulfillment_cx_or_panic ( DUMMY_SP , & mut fulfill_cx, & result)
671
671
}
672
672
673
+ /// Finishes processes any obligations that remain in the
674
+ /// fulfillment context, and then returns the result with all type
675
+ /// variables removed and regions erased. Because this is intended
676
+ /// for use after type-check has completed, if any errors occur,
677
+ /// it will panic. It is used during normalization and other cases
678
+ /// where processing the obligations in `fulfill_cx` may cause
679
+ /// type inference variables that appear in `result` to be
680
+ /// unified, and hence we need to process those obligations to get
681
+ /// the complete picture of the type.
673
682
pub fn drain_fulfillment_cx_or_panic < T > ( & self ,
674
683
span : Span ,
675
684
fulfill_cx : & mut traits:: FulfillmentContext < ' tcx > ,
@@ -679,47 +688,28 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
679
688
{
680
689
debug ! ( "drain_fulfillment_cx_or_panic()" ) ;
681
690
682
- let when = "resolving bounds after type-checking" ;
683
- let v = match self . drain_fulfillment_cx ( fulfill_cx, result) {
684
- Ok ( v) => v,
691
+ // In principle, we only need to do this so long as `result`
692
+ // contains unbound type parameters. It could be a slight
693
+ // optimization to stop iterating early.
694
+ match fulfill_cx. select_all_or_error ( self ) {
695
+ Ok ( ( ) ) => { }
685
696
Err ( errors) => {
686
- span_bug ! ( span, "Encountered errors `{:?}` {}" , errors, when) ;
697
+ span_bug ! ( span, "Encountered errors `{:?}` resolving bounds after type-checking" ,
698
+ errors) ;
687
699
}
688
- } ;
700
+ }
689
701
690
- match self . tcx . lift_to_global ( & v) {
691
- Some ( v) => v,
702
+ let result = self . resolve_type_vars_if_possible ( result) ;
703
+ let result = self . tcx . erase_regions ( & result) ;
704
+
705
+ match self . tcx . lift_to_global ( & result) {
706
+ Some ( result) => result,
692
707
None => {
693
- span_bug ! ( span, "Uninferred types/regions in `{:?}` {} " , v , when ) ;
708
+ span_bug ! ( span, "Uninferred types/regions in `{:?}`" , result ) ;
694
709
}
695
710
}
696
711
}
697
712
698
- /// Finishes processes any obligations that remain in the fulfillment
699
- /// context, and then "freshens" and returns `result`. This is
700
- /// primarily used during normalization and other cases where
701
- /// processing the obligations in `fulfill_cx` may cause type
702
- /// inference variables that appear in `result` to be unified, and
703
- /// hence we need to process those obligations to get the complete
704
- /// picture of the type.
705
- pub fn drain_fulfillment_cx < T > ( & self ,
706
- fulfill_cx : & mut traits:: FulfillmentContext < ' tcx > ,
707
- result : & T )
708
- -> Result < T , Vec < traits:: FulfillmentError < ' tcx > > >
709
- where T : TypeFoldable < ' tcx >
710
- {
711
- debug ! ( "drain_fulfillment_cx(result={:?})" ,
712
- result) ;
713
-
714
- // In principle, we only need to do this so long as `result`
715
- // contains unbound type parameters. It could be a slight
716
- // optimization to stop iterating early.
717
- fulfill_cx. select_all_or_error ( self ) ?;
718
-
719
- let result = self . resolve_type_vars_if_possible ( result) ;
720
- Ok ( self . tcx . erase_regions ( & result) )
721
- }
722
-
723
713
pub fn projection_mode ( & self ) -> Reveal {
724
714
self . projection_mode
725
715
}
0 commit comments