@@ -473,38 +473,36 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
473473 call_expr : & hir:: Expr < ' tcx > ,
474474 ) {
475475 // Next, let's construct the error
476- let ( error_span, full_call_span, ctor_of , is_method) = match & call_expr. kind {
476+ let ( error_span, full_call_span, call_name , is_method) = match & call_expr. kind {
477477 hir:: ExprKind :: Call (
478478 hir:: Expr { hir_id, span, kind : hir:: ExprKind :: Path ( qpath) , .. } ,
479479 _,
480480 ) => {
481481 if let Res :: Def ( DefKind :: Ctor ( of, _) , _) =
482482 self . typeck_results . borrow ( ) . qpath_res ( qpath, * hir_id)
483483 {
484- ( call_span, * span, Some ( of) , false )
484+ let name = match of {
485+ CtorOf :: Struct => "struct" ,
486+ CtorOf :: Variant => "enum variant" ,
487+ } ;
488+ ( call_span, * span, name, false )
485489 } else {
486- ( call_span, * span, None , false )
490+ ( call_span, * span, "function" , false )
487491 }
488492 }
489- hir:: ExprKind :: Call ( hir:: Expr { span, .. } , _) => ( call_span, * span, None , false ) ,
493+ hir:: ExprKind :: Call ( hir:: Expr { span, .. } , _) => ( call_span, * span, "function" , false ) ,
490494 hir:: ExprKind :: MethodCall ( path_segment, _, _, span) => {
491495 let ident_span = path_segment. ident . span ;
492496 let ident_span = if let Some ( args) = path_segment. args {
493497 ident_span. with_hi ( args. span_ext . hi ( ) )
494498 } else {
495499 ident_span
496500 } ;
497- // methods are never ctors
498- ( * span, ident_span, None , true )
501+ ( * span, ident_span, "method" , true )
499502 }
500503 k => span_bug ! ( call_span, "checking argument types on a non-call: `{:?}`" , k) ,
501504 } ;
502505 let args_span = error_span. trim_start ( full_call_span) . unwrap_or ( error_span) ;
503- let call_name = match ctor_of {
504- Some ( CtorOf :: Struct ) => "struct" ,
505- Some ( CtorOf :: Variant ) => "enum variant" ,
506- None => "function" ,
507- } ;
508506
509507 // Don't print if it has error types or is just plain `_`
510508 fn has_error_or_infer < ' tcx > ( tys : impl IntoIterator < Item = Ty < ' tcx > > ) -> bool {
@@ -690,8 +688,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
690688 err = tcx. sess . struct_span_err_with_code (
691689 full_call_span,
692690 & format ! (
693- "this {} takes {}{} but {} {} supplied" ,
694- call_name,
691+ "{call_name} takes {}{} but {} {} supplied" ,
695692 if c_variadic { "at least " } else { "" } ,
696693 potentially_plural_count(
697694 formal_and_expected_inputs. len( ) ,
0 commit comments