@@ -356,7 +356,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
356356 let coercion = RegionVariableOrigin :: Coercion ( self . cause . span ) ;
357357 let r_borrow = self . next_region_var ( coercion) ;
358358 let autorefd_deref_ty = Ty :: new_ref ( self . tcx , r_borrow, deref_ty, mutbl_b) ;
359-
359+
360360 // Note that we unify the autoref'd `Target` type with `b` rather than
361361 // the `Target` type with the pointee of `b`. This is necessary
362362 // to properly account for the differing variances of the pointees
@@ -804,9 +804,6 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
804804 debug_assert ! ( self . shallow_resolve( a) == a) ;
805805 debug_assert ! ( self . shallow_resolve( b) == b) ;
806806
807- let InferOk { value : b, mut obligations } =
808- self . at ( & self . cause , self . param_env ) . normalize ( b) ;
809-
810807 match b. kind ( ) {
811808 ty:: FnPtr ( _, b_hdr) => {
812809 let mut a_sig = a. fn_sig ( self . tcx ) ;
@@ -838,9 +835,10 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
838835 }
839836 }
840837
841- let InferOk { value : a_sig, obligations : o1 } =
838+ // FIXME: we shouldn't be normalizing here as coercion is inside of
839+ // a probe. This can probably cause ICEs.
840+ let InferOk { value : a_sig, mut obligations } =
842841 self . at ( & self . cause , self . param_env ) . normalize ( a_sig) ;
843- obligations. extend ( o1) ;
844842
845843 let InferOk { value, obligations : o2 } = self . coerce_from_safe_fn (
846844 a_sig,
@@ -855,8 +853,8 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
855853 }
856854 }
857855
858- /// Attempts to coerce from the type of a non-capturing closure
859- /// into a function pointer .
856+ /// Attempts to coerce from a closure to a function pointer. Fails
857+ /// if the closure has any upvars .
860858 fn coerce_closure_to_fn (
861859 & self ,
862860 a : Ty < ' tcx > ,
0 commit comments