Show actual MIR when MIR building forgot to terminate block
This makes it significantly easier to debug bugs of this kind.
This commit is contained in:
parent
9fa9ef385c
commit
760338526f
@ -762,6 +762,7 @@ where
|
|||||||
|
|
||||||
// Terminator at the bottom.
|
// Terminator at the bottom.
|
||||||
extra_data(PassWhere::BeforeLocation(current_location), w)?;
|
extra_data(PassWhere::BeforeLocation(current_location), w)?;
|
||||||
|
if data.terminator.is_some() {
|
||||||
let indented_terminator = format!("{0}{0}{1:?};", INDENT, data.terminator().kind);
|
let indented_terminator = format!("{0}{0}{1:?};", INDENT, data.terminator().kind);
|
||||||
if options.include_extra_comments {
|
if options.include_extra_comments {
|
||||||
writeln!(
|
writeln!(
|
||||||
@ -788,6 +789,7 @@ where
|
|||||||
},
|
},
|
||||||
options,
|
options,
|
||||||
)?;
|
)?;
|
||||||
|
}
|
||||||
|
|
||||||
extra_data(PassWhere::AfterLocation(current_location), w)?;
|
extra_data(PassWhere::AfterLocation(current_location), w)?;
|
||||||
extra_data(PassWhere::AfterTerminator(block), w)?;
|
extra_data(PassWhere::AfterTerminator(block), w)?;
|
||||||
|
@ -791,12 +791,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn finish(self) -> Body<'tcx> {
|
fn finish(self) -> Body<'tcx> {
|
||||||
for (index, block) in self.cfg.basic_blocks.iter().enumerate() {
|
|
||||||
if block.terminator.is_none() {
|
|
||||||
span_bug!(self.fn_span, "no terminator on block {:?}", index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut body = Body::new(
|
let mut body = Body::new(
|
||||||
MirSource::item(self.def_id.to_def_id()),
|
MirSource::item(self.def_id.to_def_id()),
|
||||||
self.cfg.basic_blocks,
|
self.cfg.basic_blocks,
|
||||||
@ -810,6 +804,23 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
body.coverage_info_hi = self.coverage_info.map(|b| b.into_done());
|
body.coverage_info_hi = self.coverage_info.map(|b| b.into_done());
|
||||||
|
|
||||||
|
for (index, block) in body.basic_blocks.iter().enumerate() {
|
||||||
|
if block.terminator.is_none() {
|
||||||
|
use rustc_middle::mir::pretty;
|
||||||
|
let options = pretty::PrettyPrintMirOptions::from_cli(self.tcx);
|
||||||
|
pretty::write_mir_fn(
|
||||||
|
self.tcx,
|
||||||
|
&body,
|
||||||
|
&mut |_, _| Ok(()),
|
||||||
|
&mut std::io::stdout(),
|
||||||
|
options,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
span_bug!(self.fn_span, "no terminator on block {:?}", index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
body
|
body
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user