mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
Rollup merge of #82362 - osa1:issue81918, r=oli-obk
Fix mir-cfg dumps Fixes #81918 Fixes #82326 (duplicate) Fixes #82325 --- r? ``@oli-obk``
This commit is contained in:
commit
aa1405fff7
@ -2,7 +2,7 @@ use gsgdt::GraphvizSettings;
|
||||
use rustc_graphviz as dot;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use std::fmt::Debug;
|
||||
use std::io::{self, Write};
|
||||
|
||||
@ -16,14 +16,27 @@ where
|
||||
{
|
||||
let def_ids = dump_mir_def_ids(tcx, single);
|
||||
|
||||
let use_subgraphs = def_ids.len() > 1;
|
||||
let mirs =
|
||||
def_ids
|
||||
.iter()
|
||||
.flat_map(|def_id| {
|
||||
if tcx.is_const_fn_raw(*def_id) {
|
||||
vec![tcx.optimized_mir(*def_id), tcx.mir_for_ctfe(*def_id)]
|
||||
} else {
|
||||
vec![tcx.instance_mir(ty::InstanceDef::Item(ty::WithOptConstParam::unknown(
|
||||
*def_id,
|
||||
)))]
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let use_subgraphs = mirs.len() > 1;
|
||||
if use_subgraphs {
|
||||
writeln!(w, "digraph __crate__ {{")?;
|
||||
}
|
||||
|
||||
for def_id in def_ids {
|
||||
let body = &tcx.optimized_mir(def_id);
|
||||
write_mir_fn_graphviz(tcx, body, use_subgraphs, w)?;
|
||||
for mir in mirs {
|
||||
write_mir_fn_graphviz(tcx, mir, use_subgraphs, w)?;
|
||||
}
|
||||
|
||||
if use_subgraphs {
|
||||
|
11
src/test/ui/issues/issue-81918.rs
Normal file
11
src/test/ui/issues/issue-81918.rs
Normal file
@ -0,0 +1,11 @@
|
||||
// check-pass
|
||||
// dont-check-compiler-stdout
|
||||
// compile-flags: -Z unpretty=mir-cfg
|
||||
|
||||
// This checks that unpretty=mir-cfg does not panic. See #81918.
|
||||
|
||||
const TAG: &'static str = "ABCD";
|
||||
|
||||
fn main() {
|
||||
if TAG == "" {}
|
||||
}
|
Loading…
Reference in New Issue
Block a user