mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-04 01:42:54 +03:00
Fix two uses of span_note when the source is not available
This commit is contained in:
@@ -218,7 +218,19 @@ pub(crate) fn report_use_of_moved_or_uninitialized(
|
||||
);
|
||||
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 @@ pub(crate) fn report_use_of_moved_or_uninitialized(
|
||||
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)) =
|
||||
|
||||
Reference in New Issue
Block a user