Skip to content

Commit cc5088d

Browse files
committed
Use more accurate lint root for mutable_borrow_reservation_conflict
1 parent 820b088 commit cc5088d

File tree

1 file changed

+8
-1
lines changed
  • src/librustc_mir/borrow_check

1 file changed

+8
-1
lines changed

src/librustc_mir/borrow_check/mod.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,16 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
268268
for (_, (place, span, context, bk, borrow)) in reservation_warnings {
269269
let mut initial_diag = mbcx.report_conflicting_borrow(context, (&place, span), bk, &borrow);
270270

271+
let lint_root = if let ClearCrossCrate::Set(ref vsi) = mbcx.mir.source_scope_local_data {
272+
let scope = mbcx.mir.source_info(context.loc).scope;
273+
vsi[scope].lint_root
274+
} else {
275+
id
276+
};
277+
271278
// Span and message don't matter; we overwrite them below anyway
272279
let mut diag = mbcx.infcx.tcx.struct_span_lint_hir(
273-
MUTABLE_BORROW_RESERVATION_CONFLICT, id, DUMMY_SP, "");
280+
MUTABLE_BORROW_RESERVATION_CONFLICT, lint_root, DUMMY_SP, "");
274281

275282
diag.message = initial_diag.styled_message().clone();
276283
diag.span = initial_diag.span.clone();

0 commit comments

Comments
 (0)