@@ -13,7 +13,6 @@ use crate::errors::{
1313 YieldExprOutsideOfCoroutine ,
1414} ;
1515use crate :: fatally_break_rust;
16- use crate :: method:: SelfSource ;
1716use crate :: type_error_struct;
1817use crate :: CoroutineTypes ;
1918use crate :: Expectation :: { self , ExpectCastableToType , ExpectHasType , NoExpectation } ;
@@ -223,7 +222,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
223222 let ty = ensure_sufficient_stack ( || match & expr. kind {
224223 hir:: ExprKind :: Path (
225224 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) ,
227226 _ => self . check_expr_kind ( expr, expected) ,
228227 } ) ;
229228 let ty = self . resolve_vars_if_possible ( ty) ;
@@ -290,7 +289,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
290289 ExprKind :: Path ( QPath :: LangItem ( lang_item, _) ) => {
291290 self . check_lang_item_path ( lang_item, expr)
292291 }
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 ) ,
294293 ExprKind :: InlineAsm ( asm) => {
295294 // We defer some asm checks as we may not have resolved the input and output types yet (they may still be infer vars).
296295 self . deferred_asm_checks . borrow_mut ( ) . push ( ( asm, expr. hir_id ) ) ;
@@ -502,12 +501,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
502501 & self ,
503502 qpath : & ' tcx hir:: QPath < ' tcx > ,
504503 expr : & ' tcx hir:: Expr < ' tcx > ,
505- args : & ' tcx [ hir:: Expr < ' tcx > ] ,
504+ args : Option < & ' tcx [ hir:: Expr < ' tcx > ] > ,
506505 call : Option < & ' tcx hir:: Expr < ' tcx > > ,
507506 ) -> Ty < ' tcx > {
508507 let tcx = self . tcx ;
509508 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 ) ;
511510 let ty = match res {
512511 Res :: Err => {
513512 self . suggest_assoc_method_call ( segs) ;
@@ -564,7 +563,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
564563 // We just want to check sizedness, so instead of introducing
565564 // placeholder lifetimes with probing, we just replace higher lifetimes
566565 // 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 ) ;
568567 let input = self . instantiate_binder_with_fresh_vars (
569568 span,
570569 infer:: BoundRegionConversionTime :: FnCall ,
@@ -1331,9 +1330,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13311330 let rcvr_t = self . check_expr ( rcvr) ;
13321331 // no need to check for bot/err -- callee does that
13331332 let rcvr_t = self . structurally_resolve_type ( rcvr. span , rcvr_t) ;
1334- let span = segment. ident . span ;
13351333
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+ {
13371336 Ok ( method) => {
13381337 // We could add a "consider `foo::<params>`" suggestion here, but I wasn't able to
13391338 // trigger this codepath causing `structurally_resolve_type` to emit an error.
@@ -1342,18 +1341,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13421341 }
13431342 Err ( error) => {
13441343 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+ {
13571347 err. emit ( ) ;
13581348 }
13591349 }
@@ -1362,7 +1352,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13621352 } ;
13631353
13641354 // 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+ )
13661363 }
13671364
13681365 fn check_expr_cast (
0 commit comments