@@ -161,7 +161,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
161161 expr : & ' tcx hir:: Expr < ' tcx > ,
162162 expected : Expectation < ' tcx > ,
163163 ) -> Ty < ' tcx > {
164- self . check_expr_with_expectation_and_args ( expr, expected, & [ ] , None )
164+ self . check_expr_with_expectation_and_args ( expr, expected, None )
165165 }
166166
167167 /// Same as `check_expr_with_expectation`, but allows us to pass in the arguments of a
@@ -170,8 +170,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
170170 & self ,
171171 expr : & ' tcx hir:: Expr < ' tcx > ,
172172 expected : Expectation < ' tcx > ,
173- args : & ' tcx [ hir:: Expr < ' tcx > ] ,
174- call : Option < & ' tcx hir:: Expr < ' tcx > > ,
173+ call_expr_and_args : Option < ( & ' tcx hir:: Expr < ' tcx > , & ' tcx [ hir:: Expr < ' tcx > ] ) > ,
175174 ) -> Ty < ' tcx > {
176175 if self . tcx ( ) . sess . verbose_internals ( ) {
177176 // make this code only run with -Zverbose-internals because it is probably slow
@@ -216,9 +215,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
216215 } ;
217216
218217 let ty = ensure_sufficient_stack ( || match & expr. kind {
218+ // Intercept the callee path expr and give it better spans.
219219 hir:: ExprKind :: Path (
220220 qpath @ ( hir:: QPath :: Resolved ( ..) | hir:: QPath :: TypeRelative ( ..) ) ,
221- ) => self . check_expr_path ( qpath, expr, Some ( args ) , call ) ,
221+ ) => self . check_expr_path ( qpath, expr, call_expr_and_args ) ,
222222 _ => self . check_expr_kind ( expr, expected) ,
223223 } ) ;
224224 let ty = self . resolve_vars_if_possible ( ty) ;
@@ -467,7 +467,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
467467 ExprKind :: Path ( QPath :: LangItem ( lang_item, _) ) => {
468468 self . check_lang_item_path ( lang_item, expr)
469469 }
470- ExprKind :: Path ( ref qpath) => self . check_expr_path ( qpath, expr, None , None ) ,
470+ ExprKind :: Path ( ref qpath) => self . check_expr_path ( qpath, expr, None ) ,
471471 ExprKind :: InlineAsm ( asm) => {
472472 // We defer some asm checks as we may not have resolved the input and output types yet (they may still be infer vars).
473473 self . deferred_asm_checks . borrow_mut ( ) . push ( ( asm, expr. hir_id ) ) ;
@@ -681,8 +681,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
681681 & self ,
682682 qpath : & ' tcx hir:: QPath < ' tcx > ,
683683 expr : & ' tcx hir:: Expr < ' tcx > ,
684- args : Option < & ' tcx [ hir:: Expr < ' tcx > ] > ,
685- call : Option < & ' tcx hir:: Expr < ' tcx > > ,
684+ call_expr_and_args : Option < ( & ' tcx hir:: Expr < ' tcx > , & ' tcx [ hir:: Expr < ' tcx > ] ) > ,
686685 ) -> Ty < ' tcx > {
687686 let tcx = self . tcx ;
688687 let ( res, opt_ty, segs) =
@@ -712,7 +711,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
712711 segs,
713712 opt_ty,
714713 res,
715- call . map_or ( expr. span , |e | e. span ) ,
714+ call_expr_and_args . map_or ( expr. span , |( e , _ ) | e. span ) ,
716715 expr. span ,
717716 expr. hir_id ,
718717 )
@@ -751,7 +750,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
751750 // We just want to check sizedness, so instead of introducing
752751 // placeholder lifetimes with probing, we just replace higher lifetimes
753752 // with fresh vars.
754- let span = args. and_then ( |args| args. get ( i) ) . map_or ( expr. span , |arg| arg. span ) ;
753+ let span = call_expr_and_args
754+ . and_then ( |( _, args) | args. get ( i) )
755+ . map_or ( expr. span , |arg| arg. span ) ;
755756 let input = self . instantiate_binder_with_fresh_vars (
756757 span,
757758 infer:: BoundRegionConversionTime :: FnCall ,
@@ -777,7 +778,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
777778 ) ;
778779 self . require_type_is_sized_deferred (
779780 output,
780- call . map_or ( expr. span , |e | e. span ) ,
781+ call_expr_and_args . map_or ( expr. span , |( e , _ ) | e. span ) ,
781782 ObligationCauseCode :: SizedCallReturnType ,
782783 ) ;
783784 }
0 commit comments