Skip to content

Commit 96f49eb

Browse files
committed
add borrows to NLL MIR dumps
1 parent 77bd47d commit 96f49eb

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

compiler/rustc_borrowck/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ fn do_mir_borrowck<'tcx>(
229229

230230
// Dump MIR results into a file, if that is enabled. This let us
231231
// write unit-tests, as well as helping with debugging.
232-
nll::dump_nll_mir(&infcx, body, &regioncx, &opt_closure_req);
232+
nll::dump_nll_mir(&infcx, body, &regioncx, &opt_closure_req, &borrow_set);
233233

234234
// We also have a `#[rustc_regions]` annotation that causes us to dump
235235
// information.

compiler/rustc_borrowck/src/nll.rs

+13
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ pub(super) fn dump_nll_mir<'tcx>(
223223
body: &Body<'tcx>,
224224
regioncx: &RegionInferenceContext<'tcx>,
225225
closure_region_requirements: &Option<ClosureRegionRequirements<'tcx>>,
226+
borrow_set: &BorrowSet<'tcx>,
226227
) {
227228
if !dump_enabled(infcx.tcx, "nll", body.source.def_id()) {
228229
return;
@@ -254,6 +255,18 @@ pub(super) fn dump_nll_mir<'tcx>(
254255
)?;
255256
writeln!(out, "|")?;
256257
}
258+
259+
if borrow_set.len() > 0 {
260+
writeln!(out, "| Borrows")?;
261+
for (borrow_idx, borrow_data) in borrow_set.iter_enumerated() {
262+
writeln!(
263+
out,
264+
"| {:?}: issued at {:?} in {:?}",
265+
borrow_idx, borrow_data.reserve_location, borrow_data.region
266+
)?;
267+
}
268+
writeln!(out, "|")?;
269+
}
257270
}
258271

259272
PassWhere::BeforeLocation(_) => {}

0 commit comments

Comments
 (0)