@@ -142,15 +142,17 @@ fn dump_matched_mir_node<'tcx, F>(
142
142
}
143
143
}
144
144
145
- /// Returns the file basename portion (without extension) of a filename path
146
- /// where we should dump a MIR representation output files.
147
- fn dump_file_basename < ' tcx > (
145
+ /// Returns the path to the filename where we should dump a given MIR.
146
+ /// Also used by other bits of code (e.g., NLL inference) that dump
147
+ /// graphviz data or other things.
148
+ fn dump_path < ' tcx > (
148
149
tcx : TyCtxt < ' tcx > ,
150
+ extension : & str ,
149
151
pass_num : bool ,
150
152
pass_name : & str ,
151
153
disambiguator : & dyn Display ,
152
154
body : & Body < ' tcx > ,
153
- ) -> String {
155
+ ) -> PathBuf {
154
156
let source = body. source ;
155
157
let promotion_id = match source. promoted {
156
158
Some ( id) => format ! ( "-{id:?}" ) ,
@@ -186,32 +188,31 @@ fn dump_file_basename<'tcx>(
186
188
_ => String :: new ( ) ,
187
189
} ;
188
190
189
- format ! (
190
- "{crate_name}.{item_name}{shim_disambiguator}{promotion_id}{pass_num}.{pass_name}.{disambiguator}" ,
191
- )
192
- }
193
-
194
- /// Returns the path to the filename where we should dump a given MIR.
195
- /// Also used by other bits of code (e.g., NLL inference) that dump
196
- /// graphviz data or other things.
197
- fn dump_path ( tcx : TyCtxt < ' _ > , basename : & str , extension : & str ) -> PathBuf {
198
191
let mut file_path = PathBuf :: new ( ) ;
199
192
file_path. push ( Path :: new ( & tcx. sess . opts . unstable_opts . dump_mir_dir ) ) ;
200
193
201
- let file_name = format ! ( "{basename}.{extension}" , ) ;
194
+ let file_name = format ! (
195
+ "{crate_name}.{item_name}{shim_disambiguator}{promotion_id}{pass_num}.{pass_name}.{disambiguator}.{extension}" ,
196
+ ) ;
202
197
203
198
file_path. push ( & file_name) ;
204
199
205
200
file_path
206
201
}
207
202
208
- /// Attempts to open the MIR dump file with the given name and extension.
209
- fn create_dump_file_with_basename (
210
- tcx : TyCtxt < ' _ > ,
211
- file_basename : & str ,
203
+ /// Attempts to open a file where we should dump a given MIR or other
204
+ /// bit of MIR-related data. Used by `mir-dump`, but also by other
205
+ /// bits of code (e.g., NLL inference) that dump graphviz data or
206
+ /// other things, and hence takes the extension as an argument.
207
+ pub fn create_dump_file < ' tcx > (
208
+ tcx : TyCtxt < ' tcx > ,
212
209
extension : & str ,
210
+ pass_num : bool ,
211
+ pass_name : & str ,
212
+ disambiguator : & dyn Display ,
213
+ body : & Body < ' tcx > ,
213
214
) -> io:: Result < io:: BufWriter < fs:: File > > {
214
- let file_path = dump_path ( tcx, file_basename , extension ) ;
215
+ let file_path = dump_path ( tcx, extension , pass_num , pass_name , disambiguator , body ) ;
215
216
if let Some ( parent) = file_path. parent ( ) {
216
217
fs:: create_dir_all ( parent) . map_err ( |e| {
217
218
io:: Error :: new (
@@ -225,25 +226,6 @@ fn create_dump_file_with_basename(
225
226
} ) ?) )
226
227
}
227
228
228
- /// Attempts to open a file where we should dump a given MIR or other
229
- /// bit of MIR-related data. Used by `mir-dump`, but also by other
230
- /// bits of code (e.g., NLL inference) that dump graphviz data or
231
- /// other things, and hence takes the extension as an argument.
232
- pub fn create_dump_file < ' tcx > (
233
- tcx : TyCtxt < ' tcx > ,
234
- extension : & str ,
235
- pass_num : bool ,
236
- pass_name : & str ,
237
- disambiguator : & dyn Display ,
238
- body : & Body < ' tcx > ,
239
- ) -> io:: Result < io:: BufWriter < fs:: File > > {
240
- create_dump_file_with_basename (
241
- tcx,
242
- & dump_file_basename ( tcx, pass_num, pass_name, disambiguator, body) ,
243
- extension,
244
- )
245
- }
246
-
247
229
///////////////////////////////////////////////////////////////////////////
248
230
// Whole MIR bodies
249
231
0 commit comments