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.rs34
-rw-r--r--compiler/rustc_borrowck/src/region_infer/graphviz.rs2
3 files changed, 23 insertions, 15 deletions
diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs
index bb1aea14693..b6398c51349 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_mir_results(&infcx, body, &regioncx, &opt_closure_req);
+    nll::dump_nll_mir(&infcx, body, &regioncx, &opt_closure_req);
 
     // 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 9256f9d306f..8b526820604 100644
--- a/compiler/rustc_borrowck/src/nll.rs
+++ b/compiler/rustc_borrowck/src/nll.rs
@@ -210,13 +210,23 @@ pub(crate) fn compute_regions<'cx, 'tcx>(
     }
 }
 
-pub(super) fn dump_mir_results<'tcx>(
+/// `-Zdump-mir=nll` dumps MIR annotated with NLL specific information:
+/// - free regions
+/// - inferred region values
+/// - region liveness
+/// - inference constraints and their causes
+///
+/// As well as graphviz `.dot` visualizations of:
+/// - the region constraints graph
+/// - the region SCC graph
+pub(super) fn dump_nll_mir<'tcx>(
     infcx: &BorrowckInferCtxt<'tcx>,
     body: &Body<'tcx>,
     regioncx: &RegionInferenceContext<'tcx>,
     closure_region_requirements: &Option<ClosureRegionRequirements<'tcx>>,
 ) {
-    if !dump_enabled(infcx.tcx, "nll", body.source.def_id()) {
+    let tcx = infcx.tcx;
+    if !dump_enabled(tcx, "nll", body.source.def_id()) {
         return;
     }
 
@@ -230,7 +240,7 @@ pub(super) fn dump_mir_results<'tcx>(
         ),
     };
     dump_mir_with_options(
-        infcx.tcx,
+        tcx,
         false,
         "nll",
         &0,
@@ -239,16 +249,14 @@ pub(super) fn dump_mir_results<'tcx>(
             match pass_where {
                 // Before the CFG, dump out the values for each region variable.
                 PassWhere::BeforeCFG => {
-                    regioncx.dump_mir(infcx.tcx, out)?;
+                    regioncx.dump_mir(tcx, out)?;
                     writeln!(out, "|")?;
 
                     if let Some(closure_region_requirements) = closure_region_requirements {
                         writeln!(out, "| Free Region Constraints")?;
-                        for_each_region_constraint(
-                            infcx.tcx,
-                            closure_region_requirements,
-                            &mut |msg| writeln!(out, "| {msg}"),
-                        )?;
+                        for_each_region_constraint(tcx, closure_region_requirements, &mut |msg| {
+                            writeln!(out, "| {msg}")
+                        })?;
                         writeln!(out, "|")?;
                     }
                 }
@@ -264,15 +272,15 @@ pub(super) fn dump_mir_results<'tcx>(
         options,
     );
 
-    // Also dump the inference graph constraints as a graphviz file.
+    // Also dump the region constraint graph as a graphviz file.
     let _: io::Result<()> = try {
-        let mut file = create_dump_file(infcx.tcx, "regioncx.all.dot", false, "nll", &0, body)?;
+        let mut file = create_dump_file(tcx, "regioncx.all.dot", false, "nll", &0, body)?;
         regioncx.dump_graphviz_raw_constraints(&mut file)?;
     };
 
-    // Also dump the inference graph constraints as a graphviz file.
+    // Also dump the region constraint SCC graph as a graphviz file.
     let _: io::Result<()> = try {
-        let mut file = create_dump_file(infcx.tcx, "regioncx.scc.dot", false, "nll", &0, body)?;
+        let mut file = create_dump_file(tcx, "regioncx.scc.dot", false, "nll", &0, body)?;
         regioncx.dump_graphviz_scc_constraints(&mut file)?;
     };
 }
diff --git a/compiler/rustc_borrowck/src/region_infer/graphviz.rs b/compiler/rustc_borrowck/src/region_infer/graphviz.rs
index 743864dd535..1936752b63c 100644
--- a/compiler/rustc_borrowck/src/region_infer/graphviz.rs
+++ b/compiler/rustc_borrowck/src/region_infer/graphviz.rs
@@ -46,7 +46,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
         dot::render(&RawConstraints { regioncx: self }, &mut w)
     }
 
-    /// Write out the region constraint graph.
+    /// Write out the region constraint SCC graph.
     pub(crate) fn dump_graphviz_scc_constraints(&self, mut w: &mut dyn Write) -> io::Result<()> {
         let mut nodes_per_scc: IndexVec<ConstraintSccIndex, _> =
             self.constraint_sccs.all_sccs().map(|_| Vec::new()).collect();