@@ -205,26 +205,6 @@ fn dump_path(tcx: TyCtxt<'_>, basename: &str, extension: &str) -> PathBuf {
205
205
file_path
206
206
}
207
207
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 ,
212
- extension : & str ,
213
- ) -> io:: Result < io:: BufWriter < fs:: File > > {
214
- let file_path = dump_path ( tcx, file_basename, extension) ;
215
- if let Some ( parent) = file_path. parent ( ) {
216
- fs:: create_dir_all ( parent) . map_err ( |e| {
217
- io:: Error :: new (
218
- e. kind ( ) ,
219
- format ! ( "IO error creating MIR dump directory: {parent:?}; {e}" ) ,
220
- )
221
- } ) ?;
222
- }
223
- Ok ( io:: BufWriter :: new ( fs:: File :: create ( & file_path) . map_err ( |e| {
224
- io:: Error :: new ( e. kind ( ) , format ! ( "IO error creating MIR dump file: {file_path:?}; {e}" ) )
225
- } ) ?) )
226
- }
227
-
228
208
/// Attempts to open a file where we should dump a given MIR or other
229
209
/// bit of MIR-related data. Used by `mir-dump`, but also by other
230
210
/// bits of code (e.g., NLL inference) that dump graphviz data or
@@ -237,11 +217,22 @@ pub fn create_dump_file<'tcx>(
237
217
disambiguator : & dyn Display ,
238
218
body : & Body < ' tcx > ,
239
219
) -> io:: Result < io:: BufWriter < fs:: File > > {
240
- create_dump_file_with_basename (
220
+ let file_path = dump_path (
241
221
tcx,
242
222
& dump_file_basename ( tcx, pass_num, pass_name, disambiguator, body) ,
243
223
extension,
244
- )
224
+ ) ;
225
+ if let Some ( parent) = file_path. parent ( ) {
226
+ fs:: create_dir_all ( parent) . map_err ( |e| {
227
+ io:: Error :: new (
228
+ e. kind ( ) ,
229
+ format ! ( "IO error creating MIR dump directory: {parent:?}; {e}" ) ,
230
+ )
231
+ } ) ?;
232
+ }
233
+ Ok ( io:: BufWriter :: new ( fs:: File :: create ( & file_path) . map_err ( |e| {
234
+ io:: Error :: new ( e. kind ( ) , format ! ( "IO error creating MIR dump file: {file_path:?}; {e}" ) )
235
+ } ) ?) )
245
236
}
246
237
247
238
///////////////////////////////////////////////////////////////////////////
0 commit comments