@@ -13,7 +13,6 @@ use crate::errors::{
13
13
YieldExprOutsideOfCoroutine ,
14
14
} ;
15
15
use crate :: fatally_break_rust;
16
- use crate :: method:: SelfSource ;
17
16
use crate :: type_error_struct;
18
17
use crate :: CoroutineTypes ;
19
18
use crate :: Expectation :: { self , ExpectCastableToType , ExpectHasType , NoExpectation } ;
@@ -223,7 +222,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
223
222
let ty = ensure_sufficient_stack ( || match & expr. kind {
224
223
hir:: ExprKind :: Path (
225
224
qpath @ ( hir:: QPath :: Resolved ( ..) | hir:: QPath :: TypeRelative ( ..) ) ,
226
- ) => self . check_expr_path ( qpath, expr, args, call) ,
225
+ ) => self . check_expr_path ( qpath, expr, Some ( args) , call) ,
227
226
_ => self . check_expr_kind ( expr, expected) ,
228
227
} ) ;
229
228
let ty = self . resolve_vars_if_possible ( ty) ;
@@ -290,7 +289,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
290
289
ExprKind :: Path ( QPath :: LangItem ( lang_item, _) ) => {
291
290
self . check_lang_item_path ( lang_item, expr)
292
291
}
293
- ExprKind :: Path ( ref qpath) => self . check_expr_path ( qpath, expr, & [ ] , None ) ,
292
+ ExprKind :: Path ( ref qpath) => self . check_expr_path ( qpath, expr, None , None ) ,
294
293
ExprKind :: InlineAsm ( asm) => {
295
294
// We defer some asm checks as we may not have resolved the input and output types yet (they may still be infer vars).
296
295
self . deferred_asm_checks . borrow_mut ( ) . push ( ( asm, expr. hir_id ) ) ;
@@ -502,12 +501,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
502
501
& self ,
503
502
qpath : & ' tcx hir:: QPath < ' tcx > ,
504
503
expr : & ' tcx hir:: Expr < ' tcx > ,
505
- args : & ' tcx [ hir:: Expr < ' tcx > ] ,
504
+ args : Option < & ' tcx [ hir:: Expr < ' tcx > ] > ,
506
505
call : Option < & ' tcx hir:: Expr < ' tcx > > ,
507
506
) -> Ty < ' tcx > {
508
507
let tcx = self . tcx ;
509
508
let ( res, opt_ty, segs) =
510
- self . resolve_ty_and_res_fully_qualified_call ( qpath, expr. hir_id , expr. span , Some ( args ) ) ;
509
+ self . resolve_ty_and_res_fully_qualified_call ( qpath, expr. hir_id , expr. span ) ;
511
510
let ty = match res {
512
511
Res :: Err => {
513
512
self . suggest_assoc_method_call ( segs) ;
@@ -564,7 +563,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
564
563
// We just want to check sizedness, so instead of introducing
565
564
// placeholder lifetimes with probing, we just replace higher lifetimes
566
565
// with fresh vars.
567
- let span = args. get ( i ) . map ( |a| a . span ) . unwrap_or ( expr. span ) ;
566
+ let span = args. and_then ( |args| args . get ( i ) ) . map_or ( expr. span , |arg| arg . span ) ;
568
567
let input = self . instantiate_binder_with_fresh_vars (
569
568
span,
570
569
infer:: BoundRegionConversionTime :: FnCall ,
@@ -1331,9 +1330,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1331
1330
let rcvr_t = self . check_expr ( rcvr) ;
1332
1331
// no need to check for bot/err -- callee does that
1333
1332
let rcvr_t = self . structurally_resolve_type ( rcvr. span , rcvr_t) ;
1334
- let span = segment. ident . span ;
1335
1333
1336
- let method = match self . lookup_method ( rcvr_t, segment, span, expr, rcvr, args) {
1334
+ let method = match self . lookup_method ( rcvr_t, segment, segment. ident . span , expr, rcvr, args)
1335
+ {
1337
1336
Ok ( method) => {
1338
1337
// We could add a "consider `foo::<params>`" suggestion here, but I wasn't able to
1339
1338
// trigger this codepath causing `structurally_resolve_type` to emit an error.
@@ -1342,18 +1341,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1342
1341
}
1343
1342
Err ( error) => {
1344
1343
if segment. ident . name != kw:: Empty {
1345
- if let Some ( err) = self . report_method_error (
1346
- span,
1347
- Some ( rcvr) ,
1348
- rcvr_t,
1349
- segment. ident ,
1350
- expr. hir_id ,
1351
- SelfSource :: MethodCall ( rcvr) ,
1352
- error,
1353
- Some ( args) ,
1354
- expected,
1355
- false ,
1356
- ) {
1344
+ if let Some ( err) =
1345
+ self . report_method_error ( expr. hir_id , rcvr_t, error, expected, false )
1346
+ {
1357
1347
err. emit ( ) ;
1358
1348
}
1359
1349
}
@@ -1362,7 +1352,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1362
1352
} ;
1363
1353
1364
1354
// Call the generic checker.
1365
- self . check_method_argument_types ( span, expr, method, args, DontTupleArguments , expected)
1355
+ self . check_method_argument_types (
1356
+ segment. ident . span ,
1357
+ expr,
1358
+ method,
1359
+ args,
1360
+ DontTupleArguments ,
1361
+ expected,
1362
+ )
1366
1363
}
1367
1364
1368
1365
fn check_expr_cast (
0 commit comments