]> git.lizzy.rs Git - rust.git/commitdiff
Use more accurate lint root for mutable_borrow_reservation_conflict
authorMatthew Jasper <mjjasper1@gmail.com>
Sun, 31 Mar 2019 12:30:51 +0000 (13:30 +0100)
committerMatthew Jasper <mjjasper1@gmail.com>
Thu, 4 Apr 2019 17:50:04 +0000 (18:50 +0100)
src/librustc_mir/borrow_check/mod.rs

index 255dc2df5b898289e7883c1b17ebaa2279c91f7c..275d958a3ed3120f904f35cb4c45836362d305b5 100644 (file)
@@ -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();