about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_borrowck/src/lib.rs2
-rw-r--r--compiler/rustc_borrowck/src/nll.rs13
-rw-r--r--src/tools/compiletest/src/runtest.rs1
-rw-r--r--tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir3
-rw-r--r--tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir3
-rw-r--r--tests/mir-opt/storage_ranges.main.nll.0.mir3
6 files changed, 24 insertions, 1 deletions
diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs
index b6398c51349..6c39d730746 100644
--- a/compiler/rustc_borrowck/src/lib.rs
+++ b/compiler/rustc_borrowck/src/lib.rs
@@ -229,7 +229,7 @@ fn do_mir_borrowck<'tcx>(
 
     // Dump MIR results into a file, if that is enabled. This let us
     // write unit-tests, as well as helping with debugging.
-    nll::dump_nll_mir(&infcx, body, &regioncx, &opt_closure_req);
+    nll::dump_nll_mir(&infcx, body, &regioncx, &opt_closure_req, &borrow_set);
 
     // We also have a `#[rustc_regions]` annotation that causes us to dump
     // information.
diff --git a/compiler/rustc_borrowck/src/nll.rs b/compiler/rustc_borrowck/src/nll.rs
index 8b526820604..5646f56ea37 100644
--- a/compiler/rustc_borrowck/src/nll.rs
+++ b/compiler/rustc_borrowck/src/nll.rs
@@ -224,6 +224,7 @@ pub(super) fn dump_nll_mir<'tcx>(
     body: &Body<'tcx>,
     regioncx: &RegionInferenceContext<'tcx>,
     closure_region_requirements: &Option<ClosureRegionRequirements<'tcx>>,
+    borrow_set: &BorrowSet<'tcx>,
 ) {
     let tcx = infcx.tcx;
     if !dump_enabled(tcx, "nll", body.source.def_id()) {
@@ -259,6 +260,18 @@ pub(super) fn dump_nll_mir<'tcx>(
                         })?;
                         writeln!(out, "|")?;
                     }
+
+                    if borrow_set.len() > 0 {
+                        writeln!(out, "| Borrows")?;
+                        for (borrow_idx, borrow_data) in borrow_set.iter_enumerated() {
+                            writeln!(
+                                out,
+                                "| {:?}: issued at {:?} in {:?}",
+                                borrow_idx, borrow_data.reserve_location, borrow_data.region
+                            )?;
+                        }
+                        writeln!(out, "|")?;
+                    }
                 }
 
                 PassWhere::BeforeLocation(_) => {}
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index eca21e55989..c18f569e528 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -2175,6 +2175,7 @@ impl<'test> TestCx<'test> {
                     "-Zvalidate-mir",
                     "-Zlint-mir",
                     "-Zdump-mir-exclude-pass-number",
+                    "-Zmir-include-spans=false", // remove span comments from NLL MIR dumps
                     "--crate-type=rlib",
                 ]);
                 if let Some(pass) = &self.props.mir_unit_test {
diff --git a/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir b/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir
index d09a422d408..7294302609a 100644
--- a/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir
+++ b/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir
@@ -20,6 +20,9 @@
 | '?2: '?3 due to Assignment at Single(bb1[0]) ($DIR/region_subtyping_basic.rs:19:13: 19:18 (#0)
 | '?3: '?4 due to Assignment at Single(bb1[3]) ($DIR/region_subtyping_basic.rs:20:13: 20:14 (#0)
 |
+| Borrows
+| bw0: issued at bb1[0] in '?2
+|
 fn main() -> () {
     let mut _0: ();
     let mut _1: [usize; ValTree(Leaf(0x00000003): usize)];
diff --git a/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir b/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir
index 4abb5b0b93b..85b89a013c4 100644
--- a/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir
+++ b/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir
@@ -20,6 +20,9 @@
 | '?2: '?3 due to Assignment at Single(bb1[0]) ($DIR/region_subtyping_basic.rs:19:13: 19:18 (#0)
 | '?3: '?4 due to Assignment at Single(bb1[3]) ($DIR/region_subtyping_basic.rs:20:13: 20:14 (#0)
 |
+| Borrows
+| bw0: issued at bb1[0] in '?2
+|
 fn main() -> () {
     let mut _0: ();
     let mut _1: [usize; ValTree(Leaf(0x0000000000000003): usize)];
diff --git a/tests/mir-opt/storage_ranges.main.nll.0.mir b/tests/mir-opt/storage_ranges.main.nll.0.mir
index bc2dcfe0a64..ae8cd0c894d 100644
--- a/tests/mir-opt/storage_ranges.main.nll.0.mir
+++ b/tests/mir-opt/storage_ranges.main.nll.0.mir
@@ -17,6 +17,9 @@
 | '?3 live at {bb0[11]}
 | '?2: '?3 due to Assignment at Single(bb0[10]) ($DIR/storage_ranges.rs:7:17: 7:25 (#0)
 |
+| Borrows
+| bw0: issued at bb0[10] in '?2
+|
 fn main() -> () {
     let mut _0: ();
     let _1: i32;