diff options
| author | Fabian Wolff <fabian.wolff@alumni.ethz.ch> | 2021-07-12 18:08:14 +0200 |
|---|---|---|
| committer | Fabian Wolff <fabian.wolff@alumni.ethz.ch> | 2021-09-09 21:17:05 +0200 |
| commit | 57fcb2e2d63306e762943b9edffa4454e89ef665 (patch) | |
| tree | 12e19932215b4f7dee86417805280d2ad47de0b0 | |
| parent | 497ee321af3b8496eaccd7af7b437f18bab81abf (diff) | |
| download | rust-57fcb2e2d63306e762943b9edffa4454e89ef665.tar.gz rust-57fcb2e2d63306e762943b9edffa4454e89ef665.zip | |
Fix two uses of `span_note` when the source is not available
| -rw-r--r-- | compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index ce1e7c14b1f..f4cbbb60b05 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -218,7 +218,19 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { ); if self.fn_self_span_reported.insert(fn_span) { err.span_note( - self_arg.span, + // Check whether the source is accessible + if self + .infcx + .tcx + .sess + .source_map() + .span_to_snippet(self_arg.span) + .is_ok() + { + self_arg.span + } else { + fn_call_span + }, "calling this operator moves the left-hand side", ); } @@ -429,7 +441,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { deref_target_ty )); - err.span_note(deref_target, "deref defined here"); + // Check first whether the source is accessible (issue #87060) + if self.infcx.tcx.sess.source_map().span_to_snippet(deref_target).is_ok() { + err.span_note(deref_target, "deref defined here"); + } } if let Some((_, mut old_err)) = |
