@@ -16,7 +16,6 @@ use rustc_middle::mir::interpret::{
1616 Pointer , Provenance ,
1717} ;
1818use rustc_middle:: mir:: visit:: Visitor ;
19- use rustc_middle:: mir:: MirSource ;
2019use rustc_middle:: mir:: * ;
2120use rustc_middle:: ty:: { self , TyCtxt } ;
2221use rustc_target:: abi:: Size ;
@@ -74,7 +73,7 @@ pub enum PassWhere {
7473#[ inline]
7574pub fn dump_mir < ' tcx , F > (
7675 tcx : TyCtxt < ' tcx > ,
77- pass_num : Option < & dyn Display > ,
76+ pass_num : bool ,
7877 pass_name : & str ,
7978 disambiguator : & dyn Display ,
8079 body : & Body < ' tcx > ,
@@ -111,7 +110,7 @@ pub fn dump_enabled<'tcx>(tcx: TyCtxt<'tcx>, pass_name: &str, def_id: DefId) ->
111110
112111fn dump_matched_mir_node < ' tcx , F > (
113112 tcx : TyCtxt < ' tcx > ,
114- pass_num : Option < & dyn Display > ,
113+ pass_num : bool ,
115114 pass_name : & str ,
116115 disambiguator : & dyn Display ,
117116 body : & Body < ' tcx > ,
@@ -120,8 +119,7 @@ fn dump_matched_mir_node<'tcx, F>(
120119 F : FnMut ( PassWhere , & mut dyn Write ) -> io:: Result < ( ) > ,
121120{
122121 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) ?;
125123 // see notes on #41697 above
126124 let def_path =
127125 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>(
143141
144142 if tcx. sess . opts . unstable_opts . dump_mir_graphviz {
145143 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) ?;
148145 write_mir_fn_graphviz ( tcx, body, false , & mut file) ?;
149146 } ;
150147 }
151148
152149 if let Some ( spanview) = tcx. sess . opts . unstable_opts . dump_mir_spanview {
153150 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) ;
156152 let mut file = create_dump_file_with_basename ( tcx, & file_basename, "html" ) ?;
157153 if body. source . def_id ( ) . is_local ( ) {
158154 write_mir_fn_spanview ( tcx, body, spanview, & file_basename, & mut file) ?;
@@ -165,11 +161,12 @@ fn dump_matched_mir_node<'tcx, F>(
165161/// where we should dump a MIR representation output files.
166162fn dump_file_basename < ' tcx > (
167163 tcx : TyCtxt < ' tcx > ,
168- pass_num : Option < & dyn Display > ,
164+ pass_num : bool ,
169165 pass_name : & str ,
170166 disambiguator : & dyn Display ,
171- source : MirSource < ' tcx > ,
167+ body : & Body < ' tcx > ,
172168) -> String {
169+ let source = body. source ;
173170 let promotion_id = match source. promoted {
174171 Some ( id) => format ! ( "-{:?}" , id) ,
175172 None => String :: new ( ) ,
@@ -178,9 +175,10 @@ fn dump_file_basename<'tcx>(
178175 let pass_num = if tcx. sess . opts . unstable_opts . dump_mir_exclude_pass_number {
179176 String :: new ( )
180177 } 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 ( )
184182 }
185183 } ;
186184
@@ -250,14 +248,14 @@ fn create_dump_file_with_basename(
250248pub fn create_dump_file < ' tcx > (
251249 tcx : TyCtxt < ' tcx > ,
252250 extension : & str ,
253- pass_num : Option < & dyn Display > ,
251+ pass_num : bool ,
254252 pass_name : & str ,
255253 disambiguator : & dyn Display ,
256- source : MirSource < ' tcx > ,
254+ body : & Body < ' tcx > ,
257255) -> io:: Result < io:: BufWriter < fs:: File > > {
258256 create_dump_file_with_basename (
259257 tcx,
260- & dump_file_basename ( tcx, pass_num, pass_name, disambiguator, source ) ,
258+ & dump_file_basename ( tcx, pass_num, pass_name, disambiguator, body ) ,
261259 extension,
262260 )
263261}
0 commit comments