@@ -78,7 +78,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
7878            _ => self . check_expr ( callee_expr) , 
7979        } ; 
8080
81-         let  expr_ty = self . structurally_resolve_type ( call_expr. span ,  original_callee_ty) ; 
81+         let  expr_ty = self . try_structurally_resolve_type ( call_expr. span ,  original_callee_ty) ; 
8282
8383        let  mut  autoderef = self . autoderef ( callee_expr. span ,  expr_ty) ; 
8484        let  mut  result = None ; 
@@ -200,7 +200,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
200200        arg_exprs :  & ' tcx  [ hir:: Expr < ' tcx > ] , 
201201        autoderef :  & Autoderef < ' a ,  ' tcx > , 
202202    )  -> Option < CallStep < ' tcx > >  { 
203-         let  adjusted_ty = self . structurally_resolve_type ( autoderef. span ( ) ,  autoderef. final_ty ( ) ) ; 
203+         let  adjusted_ty =
204+             self . try_structurally_resolve_type ( autoderef. span ( ) ,  autoderef. final_ty ( ) ) ; 
204205
205206        // If the callee is a function pointer or a closure, then we're all set. 
206207        match  * adjusted_ty. kind ( )  { 
@@ -297,6 +298,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
297298                return  None ; 
298299            } 
299300
301+             ty:: Infer ( ty:: TyVar ( vid) )  => { 
302+                 // If we end up with an inference variable which is not the hidden type of 
303+                 // an opaque, emit an error. 
304+                 if  !self . has_opaques_with_sub_unified_hidden_type ( vid)  { 
305+                     self . type_must_be_known_at_this_point ( autoderef. span ( ) ,  adjusted_ty) ; 
306+                     return  None ; 
307+                 } 
308+             } 
309+ 
300310            ty:: Error ( _)  => { 
301311                return  None ; 
302312            } 
@@ -367,35 +377,36 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
367377                Ty :: new_tup_from_iter ( self . tcx ,  arg_exprs. iter ( ) . map ( |e| self . next_ty_var ( e. span ) ) ) 
368378            } ) ; 
369379
370-             if   let  Some ( ok)  = self . lookup_method_for_operator ( 
380+             let  Some ( ok)  = self . lookup_method_for_operator ( 
371381                self . misc ( call_expr. span ) , 
372382                method_name, 
373383                trait_def_id, 
374384                adjusted_ty, 
375385                opt_input_type, 
376-             )  { 
377-                 let  method = self . register_infer_ok_obligations ( ok) ; 
378-                 let  mut  autoref = None ; 
379-                 if  borrow { 
380-                     // Check for &self vs &mut self in the method signature. Since this is either 
381-                     // the Fn or FnMut trait, it should be one of those. 
382-                     let  ty:: Ref ( _,  _,  mutbl)  = method. sig . inputs ( ) [ 0 ] . kind ( )  else  { 
383-                         bug ! ( "Expected `FnMut`/`Fn` to take receiver by-ref/by-mut" ) 
384-                     } ; 
385- 
386-                     // For initial two-phase borrow 
387-                     // deployment, conservatively omit 
388-                     // overloaded function call ops. 
389-                     let  mutbl = AutoBorrowMutability :: new ( * mutbl,  AllowTwoPhase :: No ) ; 
390- 
391-                     autoref = Some ( Adjustment  { 
392-                         kind :  Adjust :: Borrow ( AutoBorrow :: Ref ( mutbl) ) , 
393-                         target :  method. sig . inputs ( ) [ 0 ] , 
394-                     } ) ; 
395-                 } 
386+             )  else  { 
387+                 continue ; 
388+             } ; 
389+             let  method = self . register_infer_ok_obligations ( ok) ; 
390+             let  mut  autoref = None ; 
391+             if  borrow { 
392+                 // Check for &self vs &mut self in the method signature. Since this is either 
393+                 // the Fn or FnMut trait, it should be one of those. 
394+                 let  ty:: Ref ( _,  _,  mutbl)  = * method. sig . inputs ( ) [ 0 ] . kind ( )  else  { 
395+                     bug ! ( "Expected `FnMut`/`Fn` to take receiver by-ref/by-mut" ) 
396+                 } ; 
396397
397-                 return  Some ( ( autoref,  method) ) ; 
398+                 // For initial two-phase borrow 
399+                 // deployment, conservatively omit 
400+                 // overloaded function call ops. 
401+                 let  mutbl = AutoBorrowMutability :: new ( mutbl,  AllowTwoPhase :: No ) ; 
402+ 
403+                 autoref = Some ( Adjustment  { 
404+                     kind :  Adjust :: Borrow ( AutoBorrow :: Ref ( mutbl) ) , 
405+                     target :  method. sig . inputs ( ) [ 0 ] , 
406+                 } ) ; 
398407            } 
408+ 
409+             return  Some ( ( autoref,  method) ) ; 
399410        } 
400411
401412        None 
0 commit comments