]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_trans/back/lto.rs
Remove the in-tree `flate` crate
[rust.git] / src / librustc_trans / back / lto.rs
index e23ddd2542a808f8ae0b765c2c86a95ecafa3f45..a5f9a41470de48fbf35a6fee2c255538d1b53120 100644 (file)
@@ -21,8 +21,9 @@
 use back::write::{ModuleConfig, with_llvm_pmb};
 
 use libc;
-use flate;
+use flate2::read::ZlibDecoder;
 
+use std::io::Read;
 use std::ffi::CString;
 use std::path::Path;
 
@@ -112,13 +113,14 @@ pub fn run(sess: &session::Session,
                             link::RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET..
                             (link::RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET + data_size as usize)];
 
-                        match flate::inflate_bytes(compressed_data) {
-                            Ok(inflated) => inflated,
-                            Err(_) => {
-                                sess.fatal(&format!("failed to decompress bc of `{}`",
-                                                   name))
-                            }
+                        let mut inflated = Vec::new();
+                        let res = ZlibDecoder::new(compressed_data)
+                            .read_to_end(&mut inflated);
+                        if res.is_err() {
+                            sess.fatal(&format!("failed to decompress bc of `{}`",
+                                               name))
                         }
+                        inflated
                     } else {
                         sess.fatal(&format!("Unsupported bytecode format version {}",
                                            version))
@@ -129,13 +131,14 @@ pub fn run(sess: &session::Session,
                     // the object must be in the old, pre-versioning format, so
                     // simply inflate everything and let LLVM decide if it can
                     // make sense of it
-                    match flate::inflate_bytes(bc_encoded) {
-                        Ok(bc) => bc,
-                        Err(_) => {
-                            sess.fatal(&format!("failed to decompress bc of `{}`",
-                                               name))
-                        }
+                    let mut inflated = Vec::new();
+                    let res = ZlibDecoder::new(bc_encoded)
+                        .read_to_end(&mut inflated);
+                    if res.is_err() {
+                        sess.fatal(&format!("failed to decompress bc of `{}`",
+                                           name))
                     }
+                    inflated
                 })
             };