|
| 1 | +use crate::errors::{FailCreateFileEncoder, FailSeekFile, FailWriteFile}; |
1 | 2 | use crate::rmeta::def_path_hash_map::DefPathHashMapRef;
|
2 | 3 | use crate::rmeta::table::TableBuilder;
|
3 | 4 | use crate::rmeta::*;
|
@@ -2269,7 +2270,7 @@ pub fn encode_metadata(tcx: TyCtxt<'_>, path: &Path) {
|
2269 | 2270 |
|
2270 | 2271 | fn encode_metadata_impl(tcx: TyCtxt<'_>, path: &Path) {
|
2271 | 2272 | let mut encoder = opaque::FileEncoder::new(path)
|
2272 |
| - .unwrap_or_else(|err| tcx.sess.fatal(&format!("failed to create file encoder: {}", err))); |
| 2273 | + .unwrap_or_else(|err| tcx.sess.emit_fatal(FailCreateFileEncoder { err: err.to_string() })); |
2273 | 2274 | encoder.emit_raw_bytes(METADATA_HEADER);
|
2274 | 2275 |
|
2275 | 2276 | // Will be filled with the root position after encoding everything.
|
@@ -2314,10 +2315,10 @@ fn encode_metadata_impl(tcx: TyCtxt<'_>, path: &Path) {
|
2314 | 2315 | // Encode the root position.
|
2315 | 2316 | let header = METADATA_HEADER.len();
|
2316 | 2317 | file.seek(std::io::SeekFrom::Start(header as u64))
|
2317 |
| - .unwrap_or_else(|err| tcx.sess.fatal(&format!("failed to seek the file: {}", err))); |
| 2318 | + .unwrap_or_else(|err| tcx.sess.emit_fatal(FailSeekFile { err: err.to_string() })); |
2318 | 2319 | let pos = root.position.get();
|
2319 | 2320 | file.write_all(&[(pos >> 24) as u8, (pos >> 16) as u8, (pos >> 8) as u8, (pos >> 0) as u8])
|
2320 |
| - .unwrap_or_else(|err| tcx.sess.fatal(&format!("failed to write to the file: {}", err))); |
| 2321 | + .unwrap_or_else(|err| tcx.sess.emit_fatal(FailWriteFile { err: err.to_string() })); |
2321 | 2322 |
|
2322 | 2323 | // Return to the position where we are before writing the root position.
|
2323 | 2324 | file.seek(std::io::SeekFrom::Start(pos_before_seek)).unwrap();
|
|
0 commit comments