Skip to content

Commit 0119879

Browse files
committed
Auto merge of #89893 - camsteffen:redundant-dump-enabled, r=matthewjasper
Remove redundant dump_enabled check
2 parents 45b600c + 7166df4 commit 0119879

File tree

3 files changed

+8
-29
lines changed

3 files changed

+8
-29
lines changed

compiler/rustc_middle/src/mir/pretty.rs

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ pub enum PassWhere {
7171
/// or `typeck` appears in the name.
7272
/// - `foo & nll | bar & typeck` == match if `foo` and `nll` both appear in the name
7373
/// or `typeck` and `bar` both appear in the name.
74+
#[inline]
7475
pub fn dump_mir<'tcx, F>(
7576
tcx: TyCtxt<'tcx>,
7677
pass_num: Option<&dyn Display>,

compiler/rustc_mir_transform/src/dump_mir.rs

+1-25
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
//! This pass just dumps MIR at a specified point.
22
33
use std::borrow::Cow;
4-
use std::fmt;
54
use std::fs::File;
65
use std::io;
76

87
use crate::MirPass;
8+
use rustc_middle::mir::write_mir_pretty;
99
use rustc_middle::mir::Body;
10-
use rustc_middle::mir::{dump_enabled, dump_mir, write_mir_pretty};
1110
use rustc_middle::ty::TyCtxt;
1211
use rustc_session::config::{OutputFilenames, OutputType};
1312

@@ -21,29 +20,6 @@ impl<'tcx> MirPass<'tcx> for Marker {
2120
fn run_pass(&self, _tcx: TyCtxt<'tcx>, _body: &mut Body<'tcx>) {}
2221
}
2322

24-
pub struct Disambiguator {
25-
is_after: bool,
26-
}
27-
28-
impl fmt::Display for Disambiguator {
29-
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
30-
let title = if self.is_after { "after" } else { "before" };
31-
write!(formatter, "{}", title)
32-
}
33-
}
34-
35-
pub fn on_mir_pass<'tcx>(
36-
tcx: TyCtxt<'tcx>,
37-
pass_num: &dyn fmt::Display,
38-
pass_name: &str,
39-
body: &Body<'tcx>,
40-
is_after: bool,
41-
) {
42-
if dump_enabled(tcx, pass_name, body.source.def_id()) {
43-
dump_mir(tcx, Some(pass_num), pass_name, &Disambiguator { is_after }, body, |_, _| Ok(()));
44-
}
45-
}
46-
4723
pub fn emit_mir(tcx: TyCtxt<'_>, outputs: &OutputFilenames) -> io::Result<()> {
4824
let path = outputs.path(OutputType::Mir);
4925
let mut f = io::BufWriter::new(File::create(&path)?);

compiler/rustc_mir_transform/src/lib.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
2828
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
2929
use rustc_index::vec::IndexVec;
3030
use rustc_middle::mir::visit::Visitor as _;
31-
use rustc_middle::mir::{traversal, Body, ConstQualifs, MirPhase, Promoted};
31+
use rustc_middle::mir::{dump_mir, traversal, Body, ConstQualifs, MirPhase, Promoted};
3232
use rustc_middle::ty::query::Providers;
3333
use rustc_middle::ty::{self, TyCtxt, TypeFoldable};
3434
use rustc_span::{Span, Symbol};
@@ -188,12 +188,14 @@ fn run_passes(
188188
let mut index = 0;
189189
let mut run_pass = |pass: &dyn MirPass<'tcx>| {
190190
let run_hooks = |body: &_, index, is_after| {
191-
dump_mir::on_mir_pass(
191+
let disambiguator = if is_after { "after" } else { "before" };
192+
dump_mir(
192193
tcx,
193-
&format_args!("{:03}-{:03}", phase_index, index),
194+
Some(&format_args!("{:03}-{:03}", phase_index, index)),
194195
&pass.name(),
196+
&disambiguator,
195197
body,
196-
is_after,
198+
|_, _| Ok(()),
197199
);
198200
};
199201
run_hooks(body, index, false);

0 commit comments

Comments
 (0)