diff --git a/Cargo.lock b/Cargo.lock index 7131e46bcb1..4bf46643e47 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3365,7 +3365,6 @@ name = "rustc_codegen_llvm" version = "0.0.0" dependencies = [ "bitflags", - "flate2", "libc", "measureme", "rustc-demangle", @@ -3386,6 +3385,7 @@ dependencies = [ "rustc_span", "rustc_target", "smallvec 1.4.2", + "snap", "tracing", ] @@ -3711,7 +3711,6 @@ dependencies = [ name = "rustc_metadata" version = "0.0.0" dependencies = [ - "flate2", "libc", "memmap", "rustc_ast", @@ -3729,6 +3728,7 @@ dependencies = [ "rustc_span", "rustc_target", "smallvec 1.4.2", + "snap", "stable_deref_trait", "tracing", "winapi 0.3.9", @@ -4399,6 +4399,12 @@ version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" +[[package]] +name = "snap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da73c8f77aebc0e40c300b93f0a5f1bece7a248a36eee287d4e095f35c7b7d6e" + [[package]] name = "socket2" version = "0.3.12" diff --git a/src/librustc_codegen_llvm/Cargo.toml b/src/librustc_codegen_llvm/Cargo.toml index 2e4b9f22f81..d8ccaf16e28 100644 --- a/src/librustc_codegen_llvm/Cargo.toml +++ b/src/librustc_codegen_llvm/Cargo.toml @@ -12,9 +12,9 @@ doctest = false [dependencies] bitflags = "1.0" -flate2 = "1.0" libc = "0.2" measureme = "0.7.1" +snap = "1" tracing = "0.1" rustc_middle = { path = "../librustc_middle" } rustc-demangle = "0.1" diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs index b19199b9cfa..6a1b373ef07 100644 --- a/src/librustc_codegen_llvm/base.rs +++ b/src/librustc_codegen_llvm/base.rs @@ -45,15 +45,12 @@ pub fn write_compressed_metadata<'tcx>( metadata: &EncodedMetadata, llvm_module: &mut ModuleLlvm, ) { - use flate2::write::DeflateEncoder; - use flate2::Compression; + use snap::write::FrameEncoder; use std::io::Write; let (metadata_llcx, metadata_llmod) = (&*llvm_module.llcx, llvm_module.llmod()); let mut compressed = tcx.metadata_encoding_version(); - DeflateEncoder::new(&mut compressed, Compression::fast()) - .write_all(&metadata.raw_data) - .unwrap(); + FrameEncoder::new(&mut compressed).write_all(&metadata.raw_data).unwrap(); let llmeta = common::bytes_in_context(metadata_llcx, &compressed); let llconst = common::struct_in_context(metadata_llcx, &[llmeta], false); diff --git a/src/librustc_metadata/Cargo.toml b/src/librustc_metadata/Cargo.toml index af6aacfd64b..76e11bd689c 100644 --- a/src/librustc_metadata/Cargo.toml +++ b/src/librustc_metadata/Cargo.toml @@ -10,8 +10,8 @@ path = "lib.rs" doctest = false [dependencies] -flate2 = "1.0" libc = "0.2" +snap = "1" tracing = "0.1" memmap = "0.7" smallvec = { version = "1.0", features = ["union", "may_dangle"] } diff --git a/src/librustc_metadata/locator.rs b/src/librustc_metadata/locator.rs index 8fa14a44f52..0869ec28367 100644 --- a/src/librustc_metadata/locator.rs +++ b/src/librustc_metadata/locator.rs @@ -229,7 +229,7 @@ use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; use rustc_target::spec::{Target, TargetTriple}; -use flate2::read::DeflateDecoder; +use snap::read::FrameDecoder; use std::io::{Read, Result as IoResult, Write}; use std::ops::Deref; use std::path::{Path, PathBuf}; @@ -766,7 +766,7 @@ fn get_metadata_section( let compressed_bytes = &buf[header_len..]; debug!("inflating {} bytes of compressed metadata", compressed_bytes.len()); let mut inflated = Vec::new(); - match DeflateDecoder::new(compressed_bytes).read_to_end(&mut inflated) { + match FrameDecoder::new(compressed_bytes).read_to_end(&mut inflated) { Ok(_) => rustc_erase_owner!(OwningRef::new(inflated).map_owner_box()), Err(_) => { return Err(format!("failed to decompress metadata: {}", filename.display())); diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index af3fb403703..356705305d7 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -42,6 +42,7 @@ const EXCEPTIONS: &[(&str, &str)] = &[ ("crossbeam-queue", "MIT/Apache-2.0 AND BSD-2-Clause"), // rls via rayon ("arrayref", "BSD-2-Clause"), // cargo-miri/directories/.../rust-argon2 (redox) ("instant", "BSD-3-Clause"), // rustc_driver/tracing-subscriber/parking_lot + ("snap", "BSD-3-Clause"), // rustc // FIXME: this dependency violates the documentation comment above: ("fortanix-sgx-abi", "MPL-2.0"), // libstd but only for `sgx` target ]; @@ -161,6 +162,7 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[ "serde_derive", "sha-1", "smallvec", + "snap", "stable_deref_trait", "stacker", "syn",