Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
893 B
Rust
Raw Normal View History

//! This pass just dumps MIR at a specified point.
2017-02-16 16:59:09 -05:00
use std::fs::File;
use std::io;
use crate::MirPass;
use rustc_middle::mir::write_mir_pretty;
2020-04-12 10:31:00 -07:00
use rustc_middle::mir::Body;
2020-03-29 16:41:09 +02:00
use rustc_middle::ty::TyCtxt;
use rustc_session::config::{OutFileName, OutputType};
pub struct Marker(pub &'static str);
2019-08-04 16:20:00 -04:00
impl<'tcx> MirPass<'tcx> for Marker {
2023-05-15 20:23:34 +00:00
fn name(&self) -> &'static str {
2022-12-01 08:38:47 +00:00
self.0
}
fn run_pass(&self, _tcx: TyCtxt<'tcx>, _body: &mut Body<'tcx>) {}
}
pub fn emit_mir(tcx: TyCtxt<'_>) -> io::Result<()> {
match tcx.output_filenames(()).path(OutputType::Mir) {
OutFileName::Stdout => {
let mut f = io::stdout();
write_mir_pretty(tcx, None, &mut f)?;
}
OutFileName::Real(path) => {
let mut f = io::BufWriter::new(File::create(&path)?);
write_mir_pretty(tcx, None, &mut f)?;
}
}
2017-02-16 16:59:09 -05:00
Ok(())
}