diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2025-08-01 13:24:46 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2025-08-13 14:22:50 +0000 |
| commit | 7b13a509cc21dc49ae9c467038f04d9dd60994af (patch) | |
| tree | eb17cf7b343139638b5cb3c60592f41316c3c788 /compiler/rustc_mir_build | |
| parent | 1c9952f4dd6e0947ee91f07130c03813a088a894 (diff) | |
| download | rust-7b13a509cc21dc49ae9c467038f04d9dd60994af.tar.gz rust-7b13a509cc21dc49ae9c467038f04d9dd60994af.zip | |
Add a method to dump MIR in the middle of MIR building
This makes it easier to debug issues with MIR building by inserting dump_for_debugging calls around the suspected code responsible for the bad MIR.
Diffstat (limited to 'compiler/rustc_mir_build')
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/mod.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/compiler/rustc_mir_build/src/builder/mod.rs b/compiler/rustc_mir_build/src/builder/mod.rs index 855cd2f3bc0..10d0d93cb13 100644 --- a/compiler/rustc_mir_build/src/builder/mod.rs +++ b/compiler/rustc_mir_build/src/builder/mod.rs @@ -789,6 +789,28 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { builder } + #[allow(dead_code)] + fn dump_for_debugging(&self) { + let body = Body::new( + MirSource::item(self.def_id.to_def_id()), + self.cfg.basic_blocks.clone(), + self.source_scopes.clone(), + self.local_decls.clone(), + self.canonical_user_type_annotations.clone(), + self.arg_count.clone(), + self.var_debug_info.clone(), + self.fn_span.clone(), + self.coroutine.clone(), + None, + ); + //body.coverage_info_hi = self.coverage_info.clone().map(|b| b.into_done()); + + 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(); + } + fn finish(self) -> Body<'tcx> { let mut body = Body::new( MirSource::item(self.def_id.to_def_id()), |
