8000 Rollup of 8 pull requests by Zalathar · Pull Request #136222 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 8 pull requests #136222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7d9fe91
[cfg_match] Document the use of expressions
c410-f3r Jan 21, 2025
1ee7582
add NLL region graph to the polonius MIR dump
lqd Jan 26, 2025
052e9b4
add NLL SCCs to polonius MIR dump
lqd Jan 26, 2025
6bdc2dc
tidy up html structure
lqd Jan 26, 2025
cedd3e2
Update books
rustbot Jan 27, 2025
93ee180
ABI-required target features: warn when they are missing in base CPU …
RalfJung Jan 27, 2025
3f6ffa1
update comments
RalfJung Jan 27, 2025
7877d86
Add mir-opt pattern type tests
oli-obk Jan 28, 2025
fd6713f
Make mir dumps more readable
oli-obk Jan 27, 2025
6509596
ci: remove unused windows runner
marcoieni Jan 28, 2025
3026545
parse_format optimize import use
hkBst Jan 23, 2025
81a5e14
Move fulfillment error derivation into new module
compiler-errors Jan 22, 2025
5f76f1a
Manually walk into WF obligations in BestObligation proof tree visitor
compiler-errors Jan 22, 2025
5317161
Rollup merge of #135625 - c410-f3r:cfg-match-foo-bar-baz, r=tgross35,…
Zalathar Jan 29, 2025
64fc3bf
Rollup merge of #135900 - compiler-errors:derive-wf, r=lcnr
Zalathar Jan 29, 2025
9567909
Rollup merge of #135943 - hkBst:opt_imports, r=estebank
Zalathar Jan 29, 2025
74f5b28
Rollup merge of #136104 - lqd:polonius-debugger-episode-2, r=matthewj…
Zalathar Jan 29, 2025
1d35c31
Rollup merge of #136143 - rustbot:docs-update, r=ehuss
Zalathar Jan 29, 2025
efe01ea
Rollup merge of #136147 - RalfJung:required-target-features-check-not…
Zalathar Jan 29, 2025
c3c573c
Rollup merge of #136176 - oli-obk:pattern-type-mir-opts, r=compiler-e…
Zalathar Jan 29, 2025
e31f420
Rollup merge of #136192 - marcoieni:remove-windows-unused-runner, r=K…
Zalathar Jan 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add NLL SCCs to polonius MIR dump
  • Loading branch information
lqd committed Jan 26, 2025
commit 052e9b430651f5cb89b511d131d1d7a47a28d215
49 changes: 49 additions & 0 deletions compiler/rustc_borrowck/src/polonius/dump.rs
BE31
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::io;

use rustc_data_structures::fx::FxHashSet;
use rustc_index::IndexVec;
use rustc_middle::mir::pretty::{
PassWhere, PrettyPrintMirOptions, create_dump_file, dump_enabled, dump_mir_to_writer,
};
Expand Down Expand Up @@ -54,6 +55,7 @@ pub(crate) fn dump_polonius_mir<'tcx>(
/// - the list of polonius localized constraints
/// - a mermaid graph of the CFG
/// - a mermaid graph of the NLL regions and the constraints between them
/// - a mermaid graph of the NLL SCCs and the constraints between them
fn emit_polonius_dump<'tcx>(
tcx: TyCtxt<'tcx>,
body: &Body<'tcx>,
Expand Down Expand Up @@ -101,6 +103,14 @@ fn emit_polonius_dump<'tcx>(
writeln!(out, "</pre>")?;
writeln!(out, "</div>")?;

// Section 4: mermaid visualization of the NLL SCC graph.
writeln!(out, "<div>")?;
writeln!(out, "NLL SCCs")?;
writeln!(out, "<pre class='mermaid'>")?;
emit_mermaid_nll_sccs(regioncx, out)?;
writeln!(out, "</pre>")?;
writeln!(out, "</div>")?;

// Finalize the dump with the HTML epilogue.
writeln!(
out,
Expand Down Expand Up @@ -343,3 +353,42 @@ fn emit_mermaid_nll_regions<'tcx>(
}
Ok(())
}

/// Emits a mermaid flowchart of the NLL SCCs and the outlives constraints between them, similar
/// to the graphviz version.
fn emit_mermaid_nll_sccs<'tcx>(
regioncx: &RegionInferenceContext<'tcx>,
out: &mut dyn io::Write,
) -> io::Result<()> {
// The mermaid chart type: a top-down flowchart.
writeln!(out, "flowchart TD")?;

// Gather and emit the SCC nodes.
let mut nodes_per_scc: IndexVec<_, _> =
regioncx.constraint_sccs().all_sccs().map(|_| Vec::new()).collect();
for region in regioncx.var_infos.indices() {
let scc = regioncx.constraint_sccs().scc(region);
nodes_per_scc[scc].push(region);
}
for (scc, regions) in nodes_per_scc.iter_enumerated() {
// The node label: the regions contained in the SCC.
write!(out, "{scc}[\"SCC({scc}) = {{", scc = scc.as_usize())?;
for (idx, &region) in regions.iter().enumerate() {
render_region(region, regioncx, out)?;
if idx < regions.len() - 1 {
write!(out, ",")?;
}
}
writeln!(out, "}}\"]")?;
}

// Emit the edges between SCCs.
let edges = regioncx.constraint_sccs().all_sccs().flat_map(|source| {
regioncx.constraint_sccs().successors(source).iter().map(move |&target| (source, target))
});
for (source, target) in edges {
writeln!(out, "{} --> {}", source.as_usize(), target.as_usize())?;
}

Ok(())
}
0