Introduce Span::is_visible
This commit is contained in:
parent
e10201c9bb
commit
b9da55afb5
3 changed files with 12 additions and 7 deletions
|
@ -2413,19 +2413,19 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
| ObligationCauseCode::ExprBindingObligation(item_def_id, span, ..) => {
|
||||
let item_name = tcx.def_path_str(item_def_id);
|
||||
let mut multispan = MultiSpan::from(span);
|
||||
let sm = tcx.sess.source_map();
|
||||
if let Some(ident) = tcx.opt_item_ident(item_def_id) {
|
||||
let sm = tcx.sess.source_map();
|
||||
let same_line =
|
||||
match (sm.lookup_line(ident.span.hi()), sm.lookup_line(span.lo())) {
|
||||
(Ok(l), Ok(r)) => l.line == r.line,
|
||||
_ => true,
|
||||
};
|
||||
if !ident.span.is_dummy() && !ident.span.overlaps(span) && !same_line {
|
||||
if ident.span.is_visible(sm) && !ident.span.overlaps(span) && !same_line {
|
||||
multispan.push_span_label(ident.span, "required by a bound in this");
|
||||
}
|
||||
}
|
||||
let descr = format!("required by a bound in `{}`", item_name);
|
||||
if !span.is_dummy() {
|
||||
if span.is_visible(sm) {
|
||||
let msg = format!("required by this bound in `{}`", item_name);
|
||||
multispan.push_span_label(span, msg);
|
||||
err.span_note(multispan, &descr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue