@@ -114,7 +114,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
114
114
let report_candidates = |span: Span,
115
115
err: &mut Diagnostic,
116
116
sources: &mut Vec<CandidateSource>,
117
- sugg_span: Span| {
117
+ sugg_span: Option< Span> | {
118
118
sources.sort();
119
119
sources.dedup();
120
120
// Dynamic limit to avoid hiding just one candidate, which is silly.
@@ -175,7 +175,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
175
175
} else {
176
176
err.note(¬e_str);
177
177
}
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) {
179
180
let path = self.tcx.def_path_str(trait_ref.def_id);
180
181
181
182
let ty = match item.kind {
@@ -224,20 +225,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
224
225
err.span_note(item_span, msg);
225
226
None
226
227
};
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
+ }
241
244
}
242
245
}
243
246
}
@@ -407,9 +410,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
407
410
sugg_span,
408
411
);
409
412
410
- report_candidates(span, &mut err, &mut static_candidates, sugg_span );
413
+ report_candidates(span, &mut err, &mut static_candidates, None );
411
414
} 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) );
413
416
}
414
417
415
418
let mut bound_spans = vec![];
@@ -1015,7 +1018,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1015
1018
);
1016
1019
err.span_label(item_name.span, format!("multiple `{}` found", item_name));
1017
1020
1018
- report_candidates(span, &mut err, &mut sources, sugg_span);
1021
+ report_candidates(span, &mut err, &mut sources, Some( sugg_span) );
1019
1022
err.emit();
1020
1023
}
1021
1024
0 commit comments