about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJhonny Bill Mena <jhonnybillm@gmail.com>2022-11-04 01:16:16 -0400
committerJhonny Bill Mena <jhonnybillm@gmail.com>2022-11-04 01:17:03 -0400
commit540c3f94d71879f413a151bc8c83c20c10b386dc (patch)
tree8cec8329bb002dc69b0f3420586ab72930c20f50
parent28491a7b36a717e42081fc6ee788433feccb72e6 (diff)
downloadrust-540c3f94d71879f413a151bc8c83c20c10b386dc.tar.gz
rust-540c3f94d71879f413a151bc8c83c20c10b386dc.zip
UPDATE - accept dyn error and make Box<dyn error> conform to IntoDiagnosticArg
-rw-r--r--compiler/rustc_codegen_ssa/src/back/archive.rs29
-rw-r--r--compiler/rustc_codegen_ssa/src/errors.rs14
-rw-r--r--compiler/rustc_errors/src/diagnostic_impls.rs1
3 files changed, 22 insertions, 22 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs
index 9113ddab048..18789d00fd3 100644
--- a/compiler/rustc_codegen_ssa/src/back/archive.rs
+++ b/compiler/rustc_codegen_ssa/src/back/archive.rs
@@ -35,30 +35,29 @@ pub trait ArchiveBuilderBuilder {
         outdir: &Path,
         bundled_lib_file_names: &FxHashSet<Symbol>,
     ) -> Result<(), ExtractBundledLibsError<'_>> {
-        let archive_map =
-            unsafe {
-                Mmap::map(File::open(rlib).map_err(|e| ExtractBundledLibsError::OpenFile {
-                    rlib,
-                    error: e.to_string(),
-                })?)
-                .map_err(|e| ExtractBundledLibsError::MmapFile { rlib, error: e.to_string() })?
-            };
+        let archive_map = unsafe {
+            Mmap::map(
+                File::open(rlib)
+                    .map_err(|e| ExtractBundledLibsError::OpenFile { rlib, error: Box::new(e) })?,
+            )
+            .map_err(|e| ExtractBundledLibsError::MmapFile { rlib, error: Box::new(e) })?
+        };
         let archive = ArchiveFile::parse(&*archive_map)
-            .map_err(|e| ExtractBundledLibsError::ParseArchive { rlib, error: e.to_string() })?;
+            .map_err(|e| ExtractBundledLibsError::ParseArchive { rlib, error: Box::new(e) })?;
 
         for entry in archive.members() {
             let entry = entry
-                .map_err(|e| ExtractBundledLibsError::ReadEntry { rlib, error: e.to_string() })?;
-            let data = entry.data(&*archive_map).map_err(|e| {
-                ExtractBundledLibsError::ArchiveMember { rlib, error: e.to_string() }
-            })?;
+                .map_err(|e| ExtractBundledLibsError::ReadEntry { rlib, error: Box::new(e) })?;
+            let data = entry
+                .data(&*archive_map)
+                .map_err(|e| ExtractBundledLibsError::ArchiveMember { rlib, error: Box::new(e) })?;
             let name = std::str::from_utf8(entry.name())
-                .map_err(|e| ExtractBundledLibsError::ConvertName { rlib, error: e.to_string() })?;
+                .map_err(|e| ExtractBundledLibsError::ConvertName { rlib, error: Box::new(e) })?;
             if !bundled_lib_file_names.contains(&Symbol::intern(name)) {
                 continue; // We need to extract only native libraries.
             }
             std::fs::write(&outdir.join(&name), data)
-                .map_err(|e| ExtractBundledLibsError::WriteFile { rlib, error: e.to_string() })?;
+                .map_err(|e| ExtractBundledLibsError::WriteFile { rlib, error: Box::new(e) })?;
         }
         Ok(())
     }
diff --git a/compiler/rustc_codegen_ssa/src/errors.rs b/compiler/rustc_codegen_ssa/src/errors.rs
index 265f466f2ca..36c94462b0b 100644
--- a/compiler/rustc_codegen_ssa/src/errors.rs
+++ b/compiler/rustc_codegen_ssa/src/errors.rs
@@ -488,25 +488,25 @@ pub struct OptionGccOnly;
 #[derive(Diagnostic)]
 pub enum ExtractBundledLibsError<'a> {
     #[diag(codegen_ssa_extract_bundled_libs_open_file)]
-    OpenFile { rlib: &'a Path, error: String },
+    OpenFile { rlib: &'a Path, error: Box<dyn std::error::Error> },
 
     #[diag(codegen_ssa_extract_bundled_libs_mmap_file)]
-    MmapFile { rlib: &'a Path, error: String },
+    MmapFile { rlib: &'a Path, error: Box<dyn std::error::Error> },
 
     #[diag(codegen_ssa_extract_bundled_libs_parse_archive)]
-    ParseArchive { rlib: &'a Path, error: String },
+    ParseArchive { rlib: &'a Path, error: Box<dyn std::error::Error> },
 
     #[diag(codegen_ssa_extract_bundled_libs_read_entry)]
-    ReadEntry { rlib: &'a Path, error: String },
+    ReadEntry { rlib: &'a Path, error: Box<dyn std::error::Error> },
 
     #[diag(codegen_ssa_extract_bundled_libs_archive_member)]
-    ArchiveMember { rlib: &'a Path, error: String },
+    ArchiveMember { rlib: &'a Path, error: Box<dyn std::error::Error> },
 
     #[diag(codegen_ssa_extract_bundled_libs_convert_name)]
-    ConvertName { rlib: &'a Path, error: String },
+    ConvertName { rlib: &'a Path, error: Box<dyn std::error::Error> },
 
     #[diag(codegen_ssa_extract_bundled_libs_write_file)]
-    WriteFile { rlib: &'a Path, error: String },
+    WriteFile { rlib: &'a Path, error: Box<dyn std::error::Error> },
 }
 
 #[derive(Diagnostic)]
diff --git a/compiler/rustc_errors/src/diagnostic_impls.rs b/compiler/rustc_errors/src/diagnostic_impls.rs
index 4f32e236b2d..83a3211c63b 100644
--- a/compiler/rustc_errors/src/diagnostic_impls.rs
+++ b/compiler/rustc_errors/src/diagnostic_impls.rs
@@ -59,6 +59,7 @@ into_diagnostic_arg_using_display!(
     i128,
     u128,
     std::io::Error,
+    std::boxed::Box<dyn std::error::Error>,
     std::num::NonZeroU32,
     hir::Target,
     Edition,