@@ -114,7 +114,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
114114 let report_candidates = |span : Span ,
115115 err : & mut Diagnostic ,
116116 sources : & mut Vec < CandidateSource > ,
117- sugg_span : Span | {
117+ sugg_span : Option < Span > | {
118118 sources. sort ( ) ;
119119 sources. dedup ( ) ;
120120 // Dynamic limit to avoid hiding just one candidate, which is silly.
@@ -175,7 +175,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
175175 } else {
176176 err. note ( & note_str) ;
177177 }
178- if let Some ( trait_ref) = self . tcx . impl_trait_ref ( impl_did) {
178+ if let Some ( sugg_span) = sugg_span
179+ && let Some ( trait_ref) = self . tcx . impl_trait_ref ( impl_did) {
179180 let path = self . tcx . def_path_str ( trait_ref. def_id ) ;
180181
181182 let ty = match item. kind {
@@ -224,20 +225,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
224225 err. span_note ( item_span, msg) ;
225226 None
226227 } ;
227- let path = self . tcx . def_path_str ( trait_did) ;
228- print_disambiguation_help (
229- item_name,
230- args,
231- err,
232- path,
233- rcvr_ty,
234- item. kind ,
235- item. def_id ,
236- sugg_span,
237- idx,
238- self . tcx . sess . source_map ( ) ,
239- item. fn_has_self_parameter ,
240- ) ;
228+ if let Some ( sugg_span) = sugg_span {
229+ let path = self . tcx . def_path_str ( trait_did) ;
230+ print_disambiguation_help (
231+ item_name,
232+ args,
233+ err,
234+ path,
235+ rcvr_ty,
236+ item. kind ,
237+ item. def_id ,
238+ sugg_span,
239+ idx,
240+ self . tcx . sess . source_map ( ) ,
241+ item. fn_has_self_parameter ,
242+ ) ;
243+ }
241244 }
242245 }
243246 }
@@ -407,9 +410,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
407410 sugg_span,
408411 ) ;
409412
410- report_candidates ( span, & mut err, & mut static_candidates, sugg_span ) ;
413+ report_candidates ( span, & mut err, & mut static_candidates, None ) ;
411414 } else if static_candidates. len ( ) > 1 {
412- report_candidates ( span, & mut err, & mut static_candidates, sugg_span) ;
415+ report_candidates ( span, & mut err, & mut static_candidates, Some ( sugg_span) ) ;
413416 }
414417
415418 let mut bound_spans = vec ! [ ] ;
@@ -1015,7 +1018,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10151018 ) ;
10161019 err. span_label ( item_name. span , format ! ( "multiple `{}` found" , item_name) ) ;
10171020
1018- report_candidates ( span, & mut err, & mut sources, sugg_span) ;
1021+ report_candidates ( span, & mut err, & mut sources, Some ( sugg_span) ) ;
10191022 err. emit ( ) ;
10201023 }
10211024
0 commit comments