about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/back/archive.rs
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2025-02-26 13:45:35 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2025-02-26 13:45:35 +0000
commit9f190d764f3a81fc372c76d2615fd441a129d133 (patch)
tree84e347a8572c41a5aba418545d2971298d7bb208 /compiler/rustc_codegen_llvm/src/back/archive.rs
parentec451661660193bba32765b7d08b1d3ba1d21383 (diff)
downloadrust-9f190d764f3a81fc372c76d2615fd441a129d133.tar.gz
rust-9f190d764f3a81fc372c76d2615fd441a129d133.zip
Restore usage of io::Error
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/back/archive.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/back/archive.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/rustc_codegen_llvm/src/back/archive.rs b/compiler/rustc_codegen_llvm/src/back/archive.rs
index 91dce57ed1e..0a161442933 100644
--- a/compiler/rustc_codegen_llvm/src/back/archive.rs
+++ b/compiler/rustc_codegen_llvm/src/back/archive.rs
@@ -132,7 +132,7 @@ fn get_llvm_object_symbols(
     if err.is_null() {
         return Ok(true);
     } else {
-        let error = unsafe { *Box::from_raw(err as *mut String) };
+        let error = unsafe { *Box::from_raw(err as *mut io::Error) };
         // These are the magic constants for LLVM bitcode files:
         // https://github.com/llvm/llvm-project/blob/7eadc1960d199676f04add402bb0aa6f65b7b234/llvm/lib/BinaryFormat/Magic.cpp#L90-L97
         if buf.starts_with(&[0xDE, 0xCE, 0x17, 0x0B]) || buf.starts_with(&[b'B', b'C', 0xC0, 0xDE])
@@ -150,7 +150,7 @@ fn get_llvm_object_symbols(
             eprintln!("warning: Failed to read symbol table from LLVM bitcode: {}", error);
             return Ok(true);
         } else {
-            return Err(io::Error::new(io::ErrorKind::Other, format!("LLVM error: {}", error)));
+            return Err(error);
         }
     }
 
@@ -158,13 +158,16 @@ fn get_llvm_object_symbols(
         let f = unsafe { &mut *(state as *mut &mut dyn FnMut(&[u8]) -> io::Result<()>) };
         match f(unsafe { CStr::from_ptr(symbol_name) }.to_bytes()) {
             Ok(()) => std::ptr::null_mut(),
-            Err(err) => Box::into_raw(Box::new(err.to_string()) as Box<String>) as *mut c_void,
+            Err(err) => Box::into_raw(Box::new(err) as Box<io::Error>) as *mut c_void,
         }
     }
 
     unsafe extern "C" fn error_callback(error: *const c_char) -> *mut c_void {
         let error = unsafe { CStr::from_ptr(error) };
-        Box::into_raw(Box::new(error.to_string_lossy().into_owned()) as Box<String>) as *mut c_void
+        Box::into_raw(Box::new(io::Error::new(
+            io::ErrorKind::Other,
+            format!("LLVM error: {}", error.to_string_lossy()),
+        )) as Box<io::Error>) as *mut c_void
     }
 }