@@ -60,20 +60,26 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
6060 }
6161 }
6262
63- pub fn report_method_error < ' b > ( & self ,
64- span : Span ,
65- rcvr_ty : Ty < ' tcx > ,
66- item_name : ast:: Ident ,
67- source : SelfSource < ' b > ,
68- error : MethodError < ' tcx > ,
69- args : Option < & ' gcx [ hir:: Expr ] > ) {
63+ pub fn report_method_error < ' b > (
64+ & self ,
65+ span : Span ,
66+ rcvr_ty : Ty < ' tcx > ,
67+ item_name : ast:: Ident ,
68+ source : SelfSource < ' b > ,
69+ error : MethodError < ' tcx > ,
70+ args : Option < & ' gcx [ hir:: Expr ] > ,
71+ ) {
72+ let mut span = span;
7073 // Avoid suggestions when we don't know what's going on.
7174 if rcvr_ty. references_error ( ) {
7275 return ;
7376 }
7477
75- let report_candidates = |err : & mut DiagnosticBuilder < ' _ > ,
76- mut sources : Vec < CandidateSource > | {
78+ let report_candidates = |
79+ span : Span ,
80+ err : & mut DiagnosticBuilder < ' _ > ,
81+ mut sources : Vec < CandidateSource > ,
82+ | {
7783 sources. sort( ) ;
7884 sources. dedup( ) ;
7985 // Dynamic limit to avoid hiding just one candidate, which is silly.
@@ -291,9 +297,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
291297 err. emit ( ) ;
292298 return ;
293299 } else {
300+ span = item_name. span ;
294301 let mut err = struct_span_err ! (
295302 tcx. sess,
296- item_name . span,
303+ span,
297304 E0599 ,
298305 "no {} named `{}` found for type `{}` in the current scope" ,
299306 item_kind,
@@ -303,7 +310,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
303310 if let Some ( suggestion) = suggestion {
304311 // enum variant
305312 err. span_suggestion (
306- item_name . span ,
313+ span,
307314 "did you mean" ,
308315 suggestion. to_string ( ) ,
309316 Applicability :: MaybeIncorrect ,
@@ -414,9 +421,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
414421 self . ty_to_string( actual) , item_name) ) ;
415422 }
416423
417- report_candidates ( & mut err, static_sources) ;
424+ report_candidates ( span , & mut err, static_sources) ;
418425 } else if static_sources. len ( ) > 1 {
419- report_candidates ( & mut err, static_sources) ;
426+ report_candidates ( span , & mut err, static_sources) ;
420427 }
421428
422429 if !unsatisfied_predicates. is_empty ( ) {
@@ -461,7 +468,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
461468 "multiple applicable items in scope" ) ;
462469 err. span_label ( span, format ! ( "multiple `{}` found" , item_name) ) ;
463470
464- report_candidates ( & mut err, sources) ;
471+ report_candidates ( span , & mut err, sources) ;
465472 err. emit ( ) ;
466473 }
467474
0 commit comments