@@ -90,7 +90,7 @@ use rustc_back::slice::ref_slice;
90
90
use rustc:: infer:: { self , InferCtxt , InferOk , RegionVariableOrigin } ;
91
91
use rustc:: infer:: type_variable:: { TypeVariableOrigin } ;
92
92
use rustc:: ty:: subst:: { Kind , Subst , Substs } ;
93
- use rustc:: traits:: { self , ObligationCause , ObligationCauseCode , Reveal } ;
93
+ use rustc:: traits:: { self , FulfillmentContext , ObligationCause , ObligationCauseCode , Reveal } ;
94
94
use rustc:: ty:: { ParamTy , ParameterEnvironment } ;
95
95
use rustc:: ty:: { LvaluePreference , NoPreference , PreferMutLvalue } ;
96
96
use rustc:: ty:: { self , Ty , TyCtxt , Visibility } ;
@@ -2552,11 +2552,30 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
2552
2552
// No argument expectations are produced if unification fails.
2553
2553
let origin = self . misc ( call_span) ;
2554
2554
let ures = self . sub_types ( false , & origin, formal_ret, ret_ty) ;
2555
+
2555
2556
// FIXME(#15760) can't use try! here, FromError doesn't default
2556
2557
// to identity so the resulting type is not constrained.
2557
2558
match ures {
2558
- Ok ( ok) => self . register_infer_ok_obligations ( ok) ,
2559
- Err ( e) => return Err ( e) ,
2559
+ Ok ( ok) => {
2560
+ // Process any obligations locally as much as
2561
+ // we can. We don't care if some things turn
2562
+ // out unconstrained or ambiguous, as we're
2563
+ // just trying to get hints here.
2564
+ let result = self . save_and_restore_obligations_in_snapshot_flag ( |_| {
2565
+ let mut fulfill = FulfillmentContext :: new ( ) ;
2566
+ let ok = ok; // FIXME(#30046)
2567
+ for obligation in ok. obligations {
2568
+ fulfill. register_predicate_obligation ( self , obligation) ;
2569
+ }
2570
+ fulfill. select_where_possible ( self )
2571
+ } ) ;
2572
+
2573
+ match result {
2574
+ Ok ( ( ) ) => { }
2575
+ Err ( _) => return Err ( ( ) ) ,
2576
+ }
2577
+ }
2578
+ Err ( _) => return Err ( ( ) ) ,
2560
2579
}
2561
2580
2562
2581
// Record all the argument types, with the substitutions
0 commit comments