Skip to content

Commit cd084ab

Browse files
Rollup merge of rust-lang#131121 - lqd:dataflow-viz, r=compiler-errors
A couple of fixes for dataflow graphviz dumps A couple of trivial drive-by fixes to issues I noticed while debugging my buggy borrowck code: One is a fix of the `-Zdump-mir-dataflow` file extensions, the dataflow graphviz files are currently dumped as `..dot`. <details> ```console -rw-rw-r-- 1 lqd lqd 13051 Oct 1 23:21 mir_dump/issue_47680.main.-------.borrows.borrowck..dot -rw-rw-r-- 1 lqd lqd 13383 Oct 1 23:21 mir_dump/issue_47680.main.-------.ever_init.borrowck..dot -rw-rw-r-- 1 lqd lqd 13591 Oct 1 23:21 mir_dump/issue_47680.main.-------.maybe_init.borrowck..dot -rw-rw-r-- 1 lqd lqd 9257 Oct 1 23:21 mir_dump/issue_47680.main.-------.maybe_init.elaborate_drops..dot -rw-rw-r-- 1 lqd lqd 14086 Oct 1 23:21 mir_dump/issue_47680.main.-------.maybe_uninit.borrowck..dot -rw-rw-r-- 1 lqd lqd 9257 Oct 1 23:21 mir_dump/issue_47680.main.-------.maybe_uninit.elaborate_drops..dot ``` <summary>Some examples on nightly</summary> </details> And the other is for the specific `Borrows` dataflow analysis, whose domain is loans but shows locations when dumped (the location where the loan is introduced). It's not a huge deal but we didn't even print these locations in MIR dumps, and in general cross-referencing loan data (like loan liveness) is more annoying without this change. <details> ![Untitled](https://github.com/user-attachments/assets/b325a6e9-1aee-4655-8441-d3b1b55ded3c) <summary>Here's how it'll look in case inquisitive minds want to know</summary> </details> The visualization state diff display is still suboptimal in loops for some of the effects escaping a block, e.g. a gen that's not dominated/postdominated by a kill will not show up in statement diffs. (This happens in the previous screenshot, there's no `+bw1` anywhere). We can fix that in the future.
2 parents 42e3ff2 + 98d6fdb commit cd084ab

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

compiler/rustc_borrowck/src/dataflow.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::fmt;
2-
31
use rustc_data_structures::fx::FxIndexMap;
42
use rustc_data_structures::graph;
53
use rustc_index::bit_set::BitSet;
@@ -425,10 +423,6 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
425423
Borrows { tcx, body, borrow_set, borrows_out_of_scope_at_location }
426424
}
427425

428-
pub fn location(&self, idx: BorrowIndex) -> &Location {
429-
&self.borrow_set[idx].reserve_location
430-
}
431-
432426
/// Add all borrows to the kill set, if those borrows are out of scope at `location`.
433427
/// That means they went out of a nonlexical scope
434428
fn kill_loans_out_of_scope_at_location(
@@ -615,8 +609,4 @@ impl<'tcx> rustc_mir_dataflow::GenKillAnalysis<'tcx> for Borrows<'_, 'tcx> {
615609
}
616610
}
617611

618-
impl DebugWithContext<Borrows<'_, '_>> for BorrowIndex {
619-
fn fmt_with(&self, ctxt: &Borrows<'_, '_>, f: &mut fmt::Formatter<'_>) -> fmt::Result {
620-
write!(f, "{:?}", ctxt.location(*self))
621-
}
622-
}
612+
impl<C> DebugWithContext<C> for BorrowIndex {}

compiler/rustc_mir_dataflow/src/framework/engine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ where
285285
}
286286

287287
None if dump_enabled(tcx, A::NAME, def_id) => {
288-
create_dump_file(tcx, ".dot", false, A::NAME, &pass_name.unwrap_or("-----"), body)?
288+
create_dump_file(tcx, "dot", false, A::NAME, &pass_name.unwrap_or("-----"), body)?
289289
}
290290

291291
_ => return (Ok(()), results),

0 commit comments

Comments
 (0)