@@ -161,7 +161,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
161
161
expr : & ' tcx hir:: Expr < ' tcx > ,
162
162
expected : Expectation < ' tcx > ,
163
163
) -> Ty < ' tcx > {
164
- self . check_expr_with_expectation_and_args ( expr, expected, & [ ] , None )
164
+ self . check_expr_with_expectation_and_args ( expr, expected, None )
165
165
}
166
166
167
167
/// 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> {
170
170
& self ,
171
171
expr : & ' tcx hir:: Expr < ' tcx > ,
172
172
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 > ] ) > ,
175
174
) -> Ty < ' tcx > {
176
175
if self . tcx ( ) . sess . verbose_internals ( ) {
177
176
// make this code only run with -Zverbose-internals because it is probably slow
@@ -216,9 +215,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
216
215
} ;
217
216
218
217
let ty = ensure_sufficient_stack ( || match & expr. kind {
218
+ // Intercept the callee path expr and give it better spans.
219
219
hir:: ExprKind :: Path (
220
220
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 ) ,
222
222
_ => self . check_expr_kind ( expr, expected) ,
223
223
} ) ;
224
224
let ty = self . resolve_vars_if_possible ( ty) ;
@@ -467,7 +467,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
467
467
ExprKind :: Path ( QPath :: LangItem ( lang_item, _) ) => {
468
468
self . check_lang_item_path ( lang_item, expr)
469
469
}
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 ) ,
471
471
ExprKind :: InlineAsm ( asm) => {
472
472
// We defer some asm checks as we may not have resolved the input and output types yet (they may still be infer vars).
473
473
self . deferred_asm_checks . borrow_mut ( ) . push ( ( asm, expr. hir_id ) ) ;
@@ -681,8 +681,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
681
681
& self ,
682
682
qpath : & ' tcx hir:: QPath < ' tcx > ,
683
683
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 > ] ) > ,
686
685
) -> Ty < ' tcx > {
687
686
let tcx = self . tcx ;
688
687
let ( res, opt_ty, segs) =
@@ -712,7 +711,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
712
711
segs,
713
712
opt_ty,
714
713
res,
715
- call . map_or ( expr. span , |e | e. span ) ,
714
+ call_expr_and_args . map_or ( expr. span , |( e , _ ) | e. span ) ,
716
715
expr. span ,
717
716
expr. hir_id ,
718
717
)
@@ -751,7 +750,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
751
750
// We just want to check sizedness, so instead of introducing
752
751
// placeholder lifetimes with probing, we just replace higher lifetimes
753
752
// 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 ) ;
755
756
let input = self . instantiate_binder_with_fresh_vars (
756
757
span,
757
758
infer:: BoundRegionConversionTime :: FnCall ,
@@ -777,7 +778,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
777
778
) ;
778
779
self . require_type_is_sized_deferred (
779
780
output,
780
- call . map_or ( expr. span , |e | e. span ) ,
781
+ call_expr_and_args . map_or ( expr. span , |( e , _ ) | e. span ) ,
781
782
ObligationCauseCode :: SizedCallReturnType ,
782
783
) ;
783
784
}
0 commit comments