@@ -60,20 +60,26 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
60
60
}
61
61
}
62
62
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;
70
73
// Avoid suggestions when we don't know what's going on.
71
74
if rcvr_ty. references_error ( ) {
72
75
return ;
73
76
}
74
77
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
+ | {
77
83
sources. sort( ) ;
78
84
sources. dedup( ) ;
79
85
// Dynamic limit to avoid hiding just one candidate, which is silly.
@@ -291,9 +297,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
291
297
err. emit ( ) ;
292
298
return ;
293
299
} else {
300
+ span = item_name. span ;
294
301
let mut err = struct_span_err ! (
295
302
tcx. sess,
296
- item_name . span,
303
+ span,
297
304
E0599 ,
298
305
"no {} named `{}` found for type `{}` in the current scope" ,
299
306
item_kind,
@@ -303,7 +310,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
303
310
if let Some ( suggestion) = suggestion {
304
311
// enum variant
305
312
err. span_suggestion (
306
- item_name . span ,
313
+ span,
307
314
"did you mean" ,
308
315
suggestion. to_string ( ) ,
309
316
Applicability :: MaybeIncorrect ,
@@ -414,9 +421,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
414
421
self . ty_to_string( actual) , item_name) ) ;
415
422
}
416
423
417
- report_candidates ( & mut err, static_sources) ;
424
+ report_candidates ( span , & mut err, static_sources) ;
418
425
} else if static_sources. len ( ) > 1 {
419
- report_candidates ( & mut err, static_sources) ;
426
+ report_candidates ( span , & mut err, static_sources) ;
420
427
}
421
428
422
429
if !unsatisfied_predicates. is_empty ( ) {
@@ -461,7 +468,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
461
468
"multiple applicable items in scope" ) ;
462
469
err. span_label ( span, format ! ( "multiple `{}` found" , item_name) ) ;
463
470
464
- report_candidates ( & mut err, sources) ;
471
+ report_candidates ( span , & mut err, sources) ;
465
472
err. emit ( ) ;
466
473
}
467
474
0 commit comments