@@ -16,7 +16,6 @@ use rustc_middle::mir::interpret::{
16
16
Pointer , Provenance ,
17
17
} ;
18
18
use rustc_middle:: mir:: visit:: Visitor ;
19
- use rustc_middle:: mir:: MirSource ;
20
19
use rustc_middle:: mir:: * ;
21
20
use rustc_middle:: ty:: { self , TyCtxt } ;
22
21
use rustc_target:: abi:: Size ;
@@ -74,7 +73,7 @@ pub enum PassWhere {
74
73
#[ inline]
75
74
pub fn dump_mir < ' tcx , F > (
76
75
tcx : TyCtxt < ' tcx > ,
77
- pass_num : Option < & dyn Display > ,
76
+ pass_num : bool ,
78
77
pass_name : & str ,
79
78
disambiguator : & dyn Display ,
80
79
body : & Body < ' tcx > ,
@@ -111,7 +110,7 @@ pub fn dump_enabled<'tcx>(tcx: TyCtxt<'tcx>, pass_name: &str, def_id: DefId) ->
111
110
112
111
fn dump_matched_mir_node < ' tcx , F > (
113
112
tcx : TyCtxt < ' tcx > ,
114
- pass_num : Option < & dyn Display > ,
113
+ pass_num : bool ,
115
114
pass_name : & str ,
116
115
disambiguator : & dyn Display ,
117
116
body : & Body < ' tcx > ,
@@ -120,8 +119,7 @@ fn dump_matched_mir_node<'tcx, F>(
120
119
F : FnMut ( PassWhere , & mut dyn Write ) -> io:: Result < ( ) > ,
121
120
{
122
121
let _: io:: Result < ( ) > = try {
123
- let mut file =
124
- create_dump_file ( tcx, "mir" , pass_num, pass_name, disambiguator, body. source ) ?;
122
+ let mut file = create_dump_file ( tcx, "mir" , pass_num, pass_name, disambiguator, body) ?;
125
123
// see notes on #41697 above
126
124
let def_path =
127
125
ty:: print:: with_forced_impl_filename_line!( tcx. def_path_str( body. source. def_id( ) ) ) ;
@@ -143,16 +141,14 @@ fn dump_matched_mir_node<'tcx, F>(
143
141
144
142
if tcx. sess . opts . unstable_opts . dump_mir_graphviz {
145
143
let _: io:: Result < ( ) > = try {
146
- let mut file =
147
- create_dump_file ( tcx, "dot" , pass_num, pass_name, disambiguator, body. source ) ?;
144
+ let mut file = create_dump_file ( tcx, "dot" , pass_num, pass_name, disambiguator, body) ?;
148
145
write_mir_fn_graphviz ( tcx, body, false , & mut file) ?;
149
146
} ;
150
147
}
151
148
152
149
if let Some ( spanview) = tcx. sess . opts . unstable_opts . dump_mir_spanview {
153
150
let _: io:: Result < ( ) > = try {
154
- let file_basename =
155
- dump_file_basename ( tcx, pass_num, pass_name, disambiguator, body. source ) ;
151
+ let file_basename = dump_file_basename ( tcx, pass_num, pass_name, disambiguator, body) ;
156
152
let mut file = create_dump_file_with_basename ( tcx, & file_basename, "html" ) ?;
157
153
if body. source . def_id ( ) . is_local ( ) {
158
154
write_mir_fn_spanview ( tcx, body, spanview, & file_basename, & mut file) ?;
@@ -165,11 +161,12 @@ fn dump_matched_mir_node<'tcx, F>(
165
161
/// where we should dump a MIR representation output files.
166
162
fn dump_file_basename < ' tcx > (
167
163
tcx : TyCtxt < ' tcx > ,
168
- pass_num : Option < & dyn Display > ,
164
+ pass_num : bool ,
169
165
pass_name : & str ,
170
166
disambiguator : & dyn Display ,
171
- source : MirSource < ' tcx > ,
167
+ body : & Body < ' tcx > ,
172
168
) -> String {
169
+ let source = body. source ;
173
170
let promotion_id = match source. promoted {
174
171
Some ( id) => format ! ( "-{:?}" , id) ,
175
172
None => String :: new ( ) ,
@@ -178,9 +175,10 @@ fn dump_file_basename<'tcx>(
178
175
let pass_num = if tcx. sess . opts . unstable_opts . dump_mir_exclude_pass_number {
179
176
String :: new ( )
180
177
} else {
181
- match pass_num {
182
- None => ".-------" . to_string ( ) ,
183
- Some ( pass_num) => format ! ( ".{}" , pass_num) ,
178
+ if pass_num {
179
+ format ! ( ".{:03}-{:03}" , body. phase. phase_index( ) , body. pass_count)
180
+ } else {
181
+ ".-------" . to_string ( )
184
182
}
185
183
} ;
186
184
@@ -250,14 +248,14 @@ fn create_dump_file_with_basename(
250
248
pub fn create_dump_file < ' tcx > (
251
249
tcx : TyCtxt < ' tcx > ,
252
250
extension : & str ,
253
- pass_num : Option < & dyn Display > ,
251
+ pass_num : bool ,
254
252
pass_name : & str ,
255
253
disambiguator : & dyn Display ,
256
- source : MirSource < ' tcx > ,
254
+ body : & Body < ' tcx > ,
257
255
) -> io:: Result < io:: BufWriter < fs:: File > > {
258
256
create_dump_file_with_basename (
259
257
tcx,
260
- & dump_file_basename ( tcx, pass_num, pass_name, disambiguator, source ) ,
258
+ & dump_file_basename ( tcx, pass_num, pass_name, disambiguator, body ) ,
261
259
extension,
262
260
)
263
261
}
0 commit comments