diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2024-01-16 18:07:49 +1100 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2024-01-17 11:46:20 +1100 |
| commit | b82d1d32b4c4a998c0a88ea7156edc2c5b4e1439 (patch) | |
| tree | f7f1cb798f3d5f82bd63be7140c5c2e41fb2d6a9 | |
| parent | 098d4fd74c078b12bfc2e9438a2a04bc18b393bc (diff) | |
| download | rust-b82d1d32b4c4a998c0a88ea7156edc2c5b4e1439.tar.gz rust-b82d1d32b4c4a998c0a88ea7156edc2c5b4e1439.zip | |
Inline `create_dump_file_with_basename`
| -rw-r--r-- | compiler/rustc_middle/src/mir/pretty.rs | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index 239929a2c0e..5144c9b8c13 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -205,26 +205,6 @@ fn dump_path(tcx: TyCtxt<'_>, basename: &str, extension: &str) -> PathBuf { file_path } -/// Attempts to open the MIR dump file with the given name and extension. -fn create_dump_file_with_basename( - tcx: TyCtxt<'_>, - file_basename: &str, - extension: &str, -) -> io::Result<io::BufWriter<fs::File>> { - let file_path = dump_path(tcx, file_basename, extension); - if let Some(parent) = file_path.parent() { - fs::create_dir_all(parent).map_err(|e| { - io::Error::new( - e.kind(), - format!("IO error creating MIR dump directory: {parent:?}; {e}"), - ) - })?; - } - Ok(io::BufWriter::new(fs::File::create(&file_path).map_err(|e| { - io::Error::new(e.kind(), format!("IO error creating MIR dump file: {file_path:?}; {e}")) - })?)) -} - /// Attempts to open a file where we should dump a given MIR or other /// bit of MIR-related data. Used by `mir-dump`, but also by other /// bits of code (e.g., NLL inference) that dump graphviz data or @@ -237,11 +217,22 @@ pub fn create_dump_file<'tcx>( disambiguator: &dyn Display, body: &Body<'tcx>, ) -> io::Result<io::BufWriter<fs::File>> { - create_dump_file_with_basename( + let file_path = dump_path( tcx, &dump_file_basename(tcx, pass_num, pass_name, disambiguator, body), extension, - ) + ); + if let Some(parent) = file_path.parent() { + fs::create_dir_all(parent).map_err(|e| { + io::Error::new( + e.kind(), + format!("IO error creating MIR dump directory: {parent:?}; {e}"), + ) + })?; + } + Ok(io::BufWriter::new(fs::File::create(&file_path).map_err(|e| { + io::Error::new(e.kind(), format!("IO error creating MIR dump file: {file_path:?}; {e}")) + })?)) } /////////////////////////////////////////////////////////////////////////// |
