about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2019-03-31 13:30:51 +0100
committerMatthew Jasper <mjjasper1@gmail.com>2019-04-04 18:50:04 +0100
commitcc5088d2947c08732645a84d05ba51580352e0fb (patch)
tree4241825c5e4e8f9ba727c735d1aa98c8f4805379
parent820b088a215c02ae47549c9588ac121bef62a00d (diff)
downloadrust-cc5088d2947c08732645a84d05ba51580352e0fb.tar.gz
rust-cc5088d2947c08732645a84d05ba51580352e0fb.zip
Use more accurate lint root for mutable_borrow_reservation_conflict
-rw-r--r--src/librustc_mir/borrow_check/mod.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs
index 255dc2df5b8..275d958a3ed 100644
--- a/src/librustc_mir/borrow_check/mod.rs
+++ b/src/librustc_mir/borrow_check/mod.rs
@@ -268,9 +268,16 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
     for (_, (place, span, context, bk, borrow)) in reservation_warnings {
         let mut initial_diag = mbcx.report_conflicting_borrow(context, (&place, span), bk, &borrow);
 
+        let lint_root = if let ClearCrossCrate::Set(ref vsi) = mbcx.mir.source_scope_local_data {
+            let scope = mbcx.mir.source_info(context.loc).scope;
+            vsi[scope].lint_root
+        } else {
+            id
+        };
+
         // Span and message don't matter; we overwrite them below anyway
         let mut diag = mbcx.infcx.tcx.struct_span_lint_hir(
-            MUTABLE_BORROW_RESERVATION_CONFLICT, id, DUMMY_SP, "");
+            MUTABLE_BORROW_RESERVATION_CONFLICT, lint_root, DUMMY_SP, "");
 
         diag.message = initial_diag.styled_message().clone();
         diag.span = initial_diag.span.clone();