Repository: dropbox/rust-brotli (language: rust)

Issue:
Auto-format `use` statements
Use `nightly` fmt to auto-reformat all the use statements.  I will create a follow-up PR to do some manual additional cleanups. I did not want to include manual cleanups in the same PR as the initial automatic ones.

Groups `use` statements into 3 standard groups: std library, 3rd party crates, and brotli crate itself -- `StdExternalCrate` mode.

Note that the nightly fmt is required for this. It will not affect the regular `cargo fmt` CI check because regular one ignores `use` sections (the formatting has not been fully stabilized).

```
cargo +nightly fmt -- --config imports_granularity=Module,group_imports=StdExternalCrate
cd c && cargo +nightly fmt -- --config imports_granularity=Module,group_imports=StdExternalCrate
```

Note that the above steps can also be done with `just`:  `just fmt2`


Discussion / hints:

Fix patch:
diff --git a/c/src/lib.rs b/c/src/lib.rs
index 07d5e98f..9e44b3af 100644
--- a/c/src/lib.rs
+++ b/c/src/lib.rs
@@ -1,18 +1,19 @@
 #![no_std]
 #![cfg_attr(not(feature = "std"), feature(lang_items))]
+
+pub extern crate brotli;
 #[cfg(feature = "std")]
 extern crate std;
 
-pub extern crate brotli;
-pub use brotli::ffi::compressor::*;
+use core::ptr::null_mut;
 
+pub use brotli::ffi::compressor::*;
 // FIXME: this is just wrong, and needs to be fixed
 #[allow(unknown_lints, ambiguous_glob_reexports)]
 pub use brotli::ffi::decompressor::*;
-
 pub use brotli::ffi::multicompress::*;
 pub use brotli::*;
-use core::ptr::null_mut;
+
 #[cfg(feature = "std")]
 unsafe fn std_only_functions() {
     let _ =
diff --git a/justfile b/justfile
index e9c38a50..8334fbb3 100644
--- a/justfile
+++ b/justfile
@@ -32,6 +32,7 @@ fmt *ARGS:
 # Run Nightly cargo fmt, ordering imports by groups
 fmt2:
     cargo +nightly fmt -- --config imports_granularity=Module,group_imports=StdExternalCrate
+    cd c && cargo +nightly fmt -- --config imports_granularity=Module,group_imports=StdExternalCrate
 
 # Run cargo clippy
 clippy:
diff --git a/src/bin/brotli.rs b/src/bin/brotli.rs
index 6e030e85..72110558 100644
--- a/src/bin/brotli.rs
+++ b/src/bin/brotli.rs
@@ -1,24 +1,27 @@
 #![cfg_attr(feature = "benchmark", feature(test))]
 
+extern crate alloc_no_stdlib;
+extern crate brotli;
+extern crate brotli_decompressor;
+extern crate core;
+#[cfg(feature = "validation")]
+extern crate sha2;
+
 pub mod integration_tests;
 mod test_broccoli;
 mod test_custom_dict;
 mod test_threading;
 mod tests;
 mod util;
+mod validate;
 
-extern crate brotli;
-extern crate brotli_decompressor;
-extern crate core;
-#[cfg(feature = "validation")]
-extern crate sha2;
-#[allow(unused_imports)]
-#[macro_use]
-extern crate alloc_no_stdlib;
-#[allow(unused_imports)]
-use alloc_no_stdlib::{
-    bzero, AllocatedStackMemory, Allocator, SliceWrapper, SliceWrapperMut, StackAllocator,
-};
+use core::cmp::{max, min};
+use core::ops;
+use std::env;
+use std::fs::File;
+use std::io::{self, Error, ErrorKind, Read, Seek, SeekFrom, Write};
+
+use alloc_no_stdlib::{Allocator, SliceWrapper, SliceWrapperMut};
 use brotli::enc::backward_references::BrotliEncoderMode;
 use brotli::enc::threading::{
     BrotliEncoderThreadError, CompressMulti, CompressionThreadResult, Owned, SendAlloc,
@@ -28,15 +31,6 @@ use brotli::enc::{
     UnionHasher, WorkerPool,
 };
 use brotli::CustomRead;
-#[allow(unused_imports)]
-use brotli::HuffmanCode;
-use core::cmp::{max, min};
-use core::ops;
-mod validate;
-use std::env;
-
-use std::fs::File;
-use std::io::{self, Error, ErrorKind, Read, Seek, SeekFrom, Write};
 
 const MAX_THREADS: usize = 16;
 
diff --git a/src/bin/catbrotli.rs b/src/bin/catbrotli.rs
index 39a71ec0..5ba70db4 100644
--- a/src/bin/catbrotli.rs
+++ b/src/bin/catbrotli.rs
@@ -1,10 +1,9 @@
 extern crate brotli;
 extern crate core;
-use std::env;
 use std::fs::File;
-use std::io;
 use std::io::{Read, Write};
 use std::path::Path;
+use std::{env, io};
 
 use brotli::concat::{BroCatli, BroCatliResult};
 fn usage() {
diff --git a/src/bin/util.rs b/src/bin/util.rs
index 36aeb12c..352510b9 100644
--- a/src/bin/util.rs
+++ b/src/bin/util.rs
@@ -1,5 +1,8 @@
 use core::marker::PhantomData;
 use core::mem;
+use std;
+use std::collections::BTreeMap;
+use std::fmt;
 use std::thread::JoinHandle;
 
 use alloc_no_stdlib::{Allocator, SliceWrapper};
@@ -13,8 +16,6 @@ use brotli::enc::threading::{
 use brotli::enc::BrotliAlloc;
 use brotli::interface;
 use brotli::transform::TransformDictionaryWord;
-use std::collections::BTreeMap;
-use std::fmt;
 
 struct HexSlice<'a>(&'a [u8]);
 
diff --git a/src/bin/validate.rs b/src/bin/validate.rs
index 136e5d1d..5b826fce 100644
--- a/src/bin/validate.rs
+++ b/src/bin/validate.rs
@@ -1,12 +1,14 @@
-use super::{HeapAllocator, IoWriterWrapper, Rebox};
+#[cfg(feature = "validation")]
+use core;
+use std::io::{self, Error, ErrorKind, Read, Write};
+
 use alloc_no_stdlib::{Allocator, SliceWrapper};
 use brotli::enc::BrotliEncoderParams;
 use brotli::{CustomWrite, DecompressorWriterCustomIo};
 #[cfg(feature = "validation")]
-use core;
-#[cfg(feature = "validation")]
 use sha2::{Digest, Sha256};
-use std::io::{self, Error, ErrorKind, Read, Write};
+
+use super::{HeapAllocator, IoWriterWrapper, Rebox};
 #[cfg(feature = "validation")]
 type Checksum = Sha256;
 
diff --git a/src/enc/backward_references/benchmark.rs b/src/enc/backward_references/benchmark.rs
index f29492b4..de98f8b5 100644
--- a/src/enc/backward_references/benchmark.rs
+++ b/src/enc/backward_references/benchmark.rs
@@ -1,8 +1,12 @@
 #![cfg(feature = "benchmark")]
 #![cfg(feature = "std")]
+
 extern crate test;
-use super::*;
+
 use alloc_stdlib::StandardAlloc;
+
+use super::*;
+
 static RANDOM_THEN_UNICODE: &'static [u8] = include_bytes!("../../../testdata/random_then_unicode");
 static FINALIZE_DATA: &'static [u8] = &[
     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
@@ -12,6 +16,7 @@ static FINALIZE_DATA: &'static [u8] = &[
 ];
 const TEST_LEN: usize = 256 * 1024;
 const DISTANCE_CACHE: &'static [i32] = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; // distance cache
+
 fn make_generic_hasher() -> AdvHasher<H5Sub, StandardAlloc> {
     let params_hasher = BrotliHasherParams {
         type_: 5,
diff --git a/src/enc/backward_references/hash_to_binary_tree.rs b/src/enc/backward_references/hash_to_binary_tree.rs
index 2db94371..4b16b3d8 100644
--- a/src/enc/backward_references/hash_to_binary_tree.rs
+++ b/src/enc/backward_references/hash_to_binary_tree.rs
@@ -1,29 +1,19 @@
-#![allow(dead_code, unused_imports)]
-use super::{
-    kDistanceCacheIndex, kDistanceCacheOffset, kHashMul32, kHashMul64, kHashMul64Long,
-    kInvalidMatch, AnyHasher, BrotliEncoderParams, BrotliHasherParams, CloneWithAlloc, H9Opts,
-    HasherSearchResult, HowPrepared, Struct1,
-};
-use alloc;
+#![allow(dead_code)]
+
 use alloc::{Allocator, SliceWrapper, SliceWrapperMut};
-use core;
-use core::cmp::{max, min};
-use enc::command::{
-    CombineLengthCodes, Command, ComputeDistanceCode, GetCopyLengthCode, GetInsertLengthCode,
-    PrefixEncodeCopyDistance,
-};
-use enc::constants::{kCopyExtra, kInsExtra};
-use enc::dictionary_hash::kStaticDictionaryHash;
-use enc::literal_cost::BrotliEstimateBitCostsForLiterals;
-use enc::static_dict::{
-    kBrotliEncDictionary, BrotliDictionary, BrotliFindAllStaticDictionaryMatches,
-};
-use enc::static_dict::{
-    FindMatchLengthWithLimit, BROTLI_UNALIGNED_LOAD32, BROTLI_UNALIGNED_LOAD64,
+use core::cmp::min;
+
+use enc::static_dict::{BrotliDictionary, FindMatchLengthWithLimit, BROTLI_UNALIGNED_LOAD32};
+use enc::util::floatX;
+use {alloc, core};
+
+use super::{
+    kHashMul32, AnyHasher, BrotliEncoderParams, CloneWithAlloc, H9Opts, HasherSearchResult,
+    HowPrepared, Struct1,
 };
-use enc::util::{floatX, FastLog2, Log2FloorNonZero};
 
 pub const kInfinity: floatX = 1.7e38 as floatX;
+
 #[derive(Clone, Copy, Debug)]
 pub enum Union1 {
     cost(floatX),
diff --git a/src/enc/backward_references/hq.rs b/src/enc/backward_references/hq.rs
index eb646cd8..e27f148c 100644
--- a/src/enc/backward_references/hq.rs
+++ b/src/enc/backward_references/hq.rs
@@ -1,31 +1,30 @@
-#![allow(dead_code, unused_imports)]
-use super::hash_to_binary_tree::{
-    kInfinity, Allocable, BackwardMatch, BackwardMatchMut, H10Params, StoreAndFindMatchesH10,
-    Union1, ZopfliNode, H10,
-};
-use super::{
-    kDistanceCacheIndex, kDistanceCacheOffset, kHashMul32, kHashMul64, kHashMul64Long,
-    kInvalidMatch, AnyHasher, BrotliEncoderParams, BrotliHasherParams,
-};
-use alloc;
+#![allow(dead_code)]
+
 use alloc::{Allocator, SliceWrapper, SliceWrapperMut};
 use core;
 use core::cmp::{max, min};
+
 use enc::command::{
-    BrotliDistanceParams, CombineLengthCodes, Command, ComputeDistanceCode, GetCopyLengthCode,
-    GetInsertLengthCode, PrefixEncodeCopyDistance,
+    BrotliDistanceParams, CombineLengthCodes, Command, GetCopyLengthCode, GetInsertLengthCode,
+    PrefixEncodeCopyDistance,
 };
 use enc::constants::{kCopyExtra, kInsExtra};
-use enc::dictionary_hash::kStaticDictionaryHash;
 use enc::encode;
 use enc::literal_cost::BrotliEstimateBitCostsForLiterals;
 use enc::static_dict::{
-    kBrotliEncDictionary, BrotliDictionary, BrotliFindAllStaticDictionaryMatches,
+    BrotliDictionary, BrotliFindAllStaticDictionaryMatches, FindMatchLengthWithLimit,
+    BROTLI_UNALIGNED_LOAD32,
 };
-use enc::static_dict::{
-    FindMatchLengthWithLimit, BROTLI_UNALIGNED_LOAD32, BROTLI_UNALIGNED_LOAD64,
+use enc::util::{floatX, FastLog2, FastLog2f64};
+
+use super::hash_to_binary_tree::{
+    kInfinity, Allocable, BackwardMatch, BackwardMatchMut, H10Params, StoreAndFindMatchesH10,
+    Union1, ZopfliNode, H10,
+};
+use super::{
+    kDistanceCacheIndex, kDistanceCacheOffset, kHashMul32, kInvalidMatch, AnyHasher,
+    BrotliEncoderParams,
 };
-use enc::util::{floatX, FastLog2, FastLog2f64, Log2FloorNonZero};
 
 const BROTLI_WINDOW_GAP: usize = 16;
 const BROTLI_MAX_STATIC_DICTIONARY_MATCH_LEN: usize = 37;
diff --git a/src/enc/backward_references/mod.rs b/src/enc/backward_references/mod.rs
index 2b72c809..7d822612 100644
--- a/src/enc/backward_references/mod.rs
+++ b/src/enc/backward_references/mod.rs
@@ -1,20 +1,21 @@
 #![allow(dead_code)]
+
 mod benchmark;
 pub mod hash_to_binary_tree;
 pub mod hq;
 mod test;
 
+use core::cmp::{max, min};
+
 use super::super::alloc::{Allocator, SliceWrapper, SliceWrapperMut};
 use super::command::{BrotliDistanceParams, Command, ComputeDistanceCode};
 use super::dictionary_hash::kStaticDictionaryHash;
 use super::hash_to_binary_tree::{H10Buckets, H10DefaultParams, ZopfliNode, H10};
-use super::static_dict::BrotliDictionary;
 use super::static_dict::{
-    FindMatchLengthWithLimit, FindMatchLengthWithLimitMin4, BROTLI_UNALIGNED_LOAD32,
-    BROTLI_UNALIGNED_LOAD64,
+    BrotliDictionary, FindMatchLengthWithLimit, FindMatchLengthWithLimitMin4,
+    BROTLI_UNALIGNED_LOAD32, BROTLI_UNALIGNED_LOAD64,
 };
 use super::util::{floatX, Log2FloorNonZero};
-use core::cmp::{max, min};
 
 static kBrotliMinWindowBits: i32 = 10;
 static kBrotliMaxWindowBits: i32 = 24;
diff --git a/src/enc/bit_cost.rs b/src/enc/bit_cost.rs
index 45eab8b8..18c4e0a1 100644
--- a/src/enc/bit_cost.rs
+++ b/src/enc/bit_cost.rs
@@ -1,8 +1,9 @@
 #![allow(dead_code)]
-use super::super::alloc::SliceWrapper;
-use super::histogram::CostAccessors;
+
 use core::cmp::{max, min};
 
+use super::super::alloc::SliceWrapper;
+use super::histogram::CostAccessors;
 use super::util::{FastLog2, FastLog2u16};
 use super::vectorization::Mem256i;
 
diff --git a/src/enc/block_split.rs b/src/enc/block_split.rs
index 853c8bd2..041f4d0f 100644
--- a/src/enc/block_split.rs
+++ b/src/enc/block_split.rs
@@ -1,6 +1,7 @@
 #![allow(dead_code)]
-use super::super::alloc::Allocator;
-use super::super::alloc::SliceWrapper;
+
+use super::super::alloc;
+use super::super::alloc::{Allocator, SliceWrapper};
 
 pub struct BlockSplit<Alloc: alloc::Allocator<u8> + alloc::Allocator<u32>> {
     pub num_types: usize,
diff --git a/src/enc/block_splitter.rs b/src/enc/block_splitter.rs
index b6e43709..c543c6a2 100644
--- a/src/enc/block_splitter.rs
+++ b/src/enc/block_splitter.rs
@@ -1,8 +1,12 @@
 #![allow(dead_code)]
-use super::backward_references::BrotliEncoderParams;
-use super::vectorization::{sum8i, v256, v256i, Mem256f};
+
+use core;
+use core::cmp::{max, min};
+#[cfg(feature = "simd")]
+use core::simd::prelude::{SimdFloat, SimdPartialOrd};
 
 use super::super::alloc::{Allocator, SliceWrapper, SliceWrapperMut};
+use super::backward_references::BrotliEncoderParams;
 use super::bit_cost::BrotliPopulationCost;
 use super::block_split::BlockSplit;
 use super::cluster::{BrotliHistogramBitCostDistance, BrotliHistogramCombine, HistogramPair};
@@ -12,9 +16,7 @@ use super::histogram::{
     HistogramClear, HistogramCommand, HistogramDistance, HistogramLiteral,
 };
 use super::util::FastLog2;
-use core::cmp::{max, min};
-#[cfg(feature = "simd")]
-use core::simd::prelude::{SimdFloat, SimdPartialOrd};
+use super::vectorization::{sum8i, v256, v256i, Mem256f};
 
 static kMaxLiteralHistograms: usize = 100usize;
 
diff --git a/src/enc/brotli_bit_stream.rs b/src/enc/brotli_bit_stream.rs
index 124196ab..07d8efb3 100644
--- a/src/enc/brotli_bit_stream.rs
+++ b/src/enc/brotli_bit_stream.rs
@@ -1,27 +1,22 @@
 #![allow(unknown_lints)]
 #![allow(dead_code)]
-#![allow(unused_imports)]
 #![allow(unused_macros)]
-use super::combined_alloc::BrotliAlloc;
-use super::prior_eval;
-use super::stride_eval;
-use super::util::floatX;
-use super::{s16, v8};
+
+use core::cmp::{max, min};
 #[cfg(feature = "std")]
 use std::io::Write;
-use VERSION;
 
-use super::block_split::BlockSplit;
-use super::input_pair::{InputPair, InputReference, InputReferenceMut};
 use enc::backward_references::BrotliEncoderParams;
+use VERSION;
 
-use super::super::alloc;
 use super::super::alloc::{Allocator, SliceWrapper, SliceWrapperMut};
-use super::super::core;
 use super::super::dictionary::{
     kBrotliDictionary, kBrotliDictionaryOffsetsByLength, kBrotliDictionarySizeBitsByLength,
 };
 use super::super::transform::TransformDictionaryWord;
+use super::super::{alloc, core};
+use super::block_split::BlockSplit;
+use super::combined_alloc::BrotliAlloc;
 use super::command::{Command, GetCopyLengthCode, GetInsertLengthCode};
 use super::constants::{
     kCodeLengthBits, kCodeLengthDepth, kCopyBase, kCopyExtra, kInsBase, kInsExtra,
@@ -35,16 +30,15 @@ use super::entropy_encode::{
     BrotliConvertBitDepthsToSymbols, BrotliCreateHuffmanTree, BrotliSetDepth,
     BrotliWriteHuffmanTree, HuffmanComparator, HuffmanTree, SortHuffmanTreeItems,
 };
-use super::find_stride;
 use super::histogram::{
     ContextType, HistogramAddItem, HistogramCommand, HistogramDistance, HistogramLiteral,
 };
-use super::interface;
-use super::interface::{CommandProcessor, StaticCommand};
-use super::pdf::PDF;
+use super::input_pair::{InputPair, InputReference, InputReferenceMut};
+use super::interface::StaticCommand;
 use super::static_dict::kNumDistanceCacheEntries;
-use super::vectorization::Mem256f;
-use core::cmp::{max, min};
+use super::util::floatX;
+use super::{find_stride, interface, prior_eval, stride_eval};
+
 pub struct PrefixCodeRange {
     pub offset: u32,
     pub nbits: u32,
@@ -2960,8 +2954,10 @@ pub fn BrotliWriteMetadataMetaBlock(
     }
 }
 
+#[cfg(test)]
 mod test {
-    use super::{encode_base_128, MAX_SIZE_ENCODING};
+    use enc::brotli_bit_stream::{encode_base_128, MAX_SIZE_ENCODING};
+
     #[test]
     fn test_encode_base_128() {
         assert_eq!(encode_base_128(0), (1, [0u8; MAX_SIZE_ENCODING]));
diff --git a/src/enc/cluster.rs b/src/enc/cluster.rs
index dbf1c12d..7cb6b51e 100644
--- a/src/enc/cluster.rs
+++ b/src/enc/cluster.rs
@@ -1,11 +1,16 @@
 #![allow(dead_code)]
+
+use alloc::{Allocator, SliceWrapper, SliceWrapperMut};
+use core::cmp::min;
+
+use {alloc, core};
+
 use super::bit_cost::BrotliPopulationCost;
 use super::histogram::{
     CostAccessors, HistogramAddHistogram, HistogramClear, HistogramSelfAddHistogram,
 };
 use super::util::FastLog2;
-use alloc::{Allocator, SliceWrapper, SliceWrapperMut};
-use core::cmp::min;
+
 #[derive(Clone, Copy)]
 pub struct HistogramPair {
     pub idx1: u32,
diff --git a/src/enc/combined_alloc.rs b/src/enc/combined_alloc.rs
index a7b7a408..c40c8609 100644
--- a/src/enc/combined_alloc.rs
+++ b/src/enc/combined_alloc.rs
@@ -1,17 +1,16 @@
+pub use alloc::Allocator;
+
+#[cfg(feature = "std")]
+use alloc_stdlib::StandardAlloc;
+
 use super::cluster::HistogramPair;
 use super::command::Command;
+use super::entropy_encode::HuffmanTree;
+use super::hash_to_binary_tree::ZopfliNode;
 use super::histogram::{ContextType, HistogramCommand, HistogramDistance, HistogramLiteral};
 use super::interface::StaticCommand;
-use super::s16;
 use super::util::floatX;
-use super::v8;
-use super::PDF;
-pub use alloc::Allocator;
-
-use super::entropy_encode::HuffmanTree;
-use super::hash_to_binary_tree::ZopfliNode;
-#[cfg(feature = "std")]
-use alloc_stdlib::StandardAlloc;
+use super::{s16, v8, PDF};
 /*
 struct CombiningAllocator<T1, T2, AllocT1:Allocator<T1>, AllocT2:Allocator<T2>>(AllocT1, AllocT2);
 
diff --git a/src/enc/compat.rs b/src/enc/compat.rs
index 4f89db8b..77d85b35 100644
--- a/src/enc/compat.rs
+++ b/src/enc/compat.rs
@@ -1,4 +1,5 @@
 #![cfg_attr(feature = "simd", allow(unused))]
+
 use core::ops::{Add, AddAssign, BitAnd, Index, IndexMut, Mul, Shr, Sub};
 
 #[derive(Default, Copy, Clone, Debug)]
diff --git a/src/enc/compress_fragment.rs b/src/enc/compress_fragment.rs
index 65195d3a..5bd6d593 100644
--- a/src/enc/compress_fragment.rs
+++ b/src/enc/compress_fragment.rs
@@ -1,14 +1,16 @@
 #![allow(dead_code)]
-use super::backward_references::kHashMul32;
-//use super::super::alloc::{SliceWrapper, SliceWrapperMut};
 
-use super::brotli_bit_stream::{BrotliBuildAndStoreHuffmanTreeFast, BrotliStoreHuffmanTree};
+use core::cmp::min;
+
 //caution: lots of the functions look structurally the same as two_pass,
 // but have subtle index differences
 // examples: IsMatch checks p1[4] and p1[5]
 // the hoops that BuildAndStoreCommandPrefixCode goes through are subtly different in order
 // (eg memcpy x+24, y instead of +24, y+40
 // pretty much assume compress_fragment_two_pass is a trap! except for BrotliStoreMetaBlockHeader
+use super::super::alloc;
+use super::backward_references::kHashMul32;
+use super::brotli_bit_stream::{BrotliBuildAndStoreHuffmanTreeFast, BrotliStoreHuffmanTree};
 use super::compress_fragment_two_pass::{memcpy, BrotliStoreMetaBlockHeader, BrotliWriteBits};
 use super::entropy_encode::{
     BrotliConvertBitDepthsToSymbols, BrotliCreateHuffmanTree, HuffmanTree,
@@ -17,7 +19,7 @@ use super::static_dict::{
     FindMatchLengthWithLimit, BROTLI_UNALIGNED_LOAD32, BROTLI_UNALIGNED_LOAD64,
 };
 use super::util::{FastLog2, Log2FloorNonZero};
-use core::cmp::min;
+//use super::super::alloc::{SliceWrapper, SliceWrapperMut};
 
 //static kHashMul32: u32 = 0x1e35a7bdu32;
 
diff --git a/src/enc/compress_fragment_two_pass.rs b/src/enc/compress_fragment_two_pass.rs
index d35ff718..29c1044a 100644
--- a/src/enc/compress_fragment_two_pass.rs
+++ b/src/enc/compress_fragment_two_pass.rs
@@ -1,4 +1,9 @@
 #![allow(dead_code)]
+
+use core;
+use core::cmp::min;
+
+use super::super::alloc;
 use super::backward_references::kHashMul32;
 use super::bit_cost::BitsEntropy;
 use super::brotli_bit_stream::{BrotliBuildAndStoreHuffmanTreeFast, BrotliStoreHuffmanTree};
@@ -10,7 +15,8 @@ use super::static_dict::{
     BROTLI_UNALIGNED_STORE64,
 };
 use super::util::Log2FloorNonZero;
-use core::cmp::min;
+//use super::super::alloc::{SliceWrapper, SliceWrapperMut};
+
 static kCompressFragmentTwoPassBlockSize: usize = (1i32 << 17) as usize;
 
 // returns number of commands inserted
diff --git a/src/enc/constants.rs b/src/enc/constants.rs
index 6ea8ce4d..4dfde29d 100644
--- a/src/enc/constants.rs
+++ b/src/enc/constants.rs
@@ -1,4 +1,5 @@
 #![allow(dead_code)]
+
 pub const BROTLI_NUM_BLOCK_LEN_SYMBOLS: usize = 26;
 pub static kInsBase: [u32; 24] = [
     0, 1, 2, 3, 4, 5, 6, 8, 10, 14, 18, 26, 34, 50, 66, 98, 130, 194, 322, 578, 1090, 2114, 6210,
diff --git a/src/enc/context_map_entropy.rs b/src/enc/context_map_entropy.rs
index 28754c59..e66380cf 100644
--- a/src/enc/context_map_entropy.rs
+++ b/src/enc/context_map_entropy.rs
@@ -1,10 +1,12 @@
+use core;
+
+use super::super::alloc;
 use super::super::alloc::{Allocator, SliceWrapper, SliceWrapperMut};
-use super::find_stride;
 use super::input_pair::{InputPair, InputReference, InputReferenceMut};
-use super::interface;
 pub use super::ir_interpret::{push_base, Context, IRInterpreter};
 use super::util::{floatX, FastLog2u16};
 use super::weights::{Weights, BLEND_FIXED_POINT_PRECISION};
+use super::{find_stride, interface};
 
 const DEFAULT_CM_SPEED_INDEX: usize = 8;
 const NUM_SPEEDS_TO_TRY: usize = 16;
diff --git a/src/enc/dictionary_hash.rs b/src/enc/dictionary_hash.rs
index 49717483..190b6ab1 100644
--- a/src/enc/dictionary_hash.rs
+++ b/src/enc/dictionary_hash.rs
@@ -1,4 +1,5 @@
 #![allow(dead_code)]
+
 pub static kStaticDictionaryHash: [u16; 32768] = [
     32072, 0, 0, 0, 0, 0, 0, 0, 0, 21860, 0, 0, 0, 0, 0, 0, 0, 40486, 0, 0, 0, 0, 0, 45798, 0, 0,
     0, 0, 0, 0, 1292, 0, 0, 0, 0, 4964, 278, 23717, 0, 19972, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
diff --git a/src/enc/encode.rs b/src/enc/encode.rs
index e868809a..1765b17a 100644
--- a/src/enc/encode.rs
+++ b/src/enc/encode.rs
@@ -1,4 +1,13 @@
 #![allow(dead_code)]
+
+use alloc::Allocator;
+use core;
+use core::cmp::{max, min};
+
+use enc::input_pair::InputReferenceMut;
+
+use super::super::alloc;
+use super::super::alloc::{SliceWrapper, SliceWrapperMut};
 use super::backward_references::{
     AdvHashSpecialization, AdvHasher, AnyHasher, BasicHasher, BrotliCreateBackwardReferences,
     BrotliEncoderMode, BrotliEncoderParams, BrotliHasherParams, H2Sub, H3Sub, H4Sub, H54Sub, H5Sub,
@@ -6,45 +15,33 @@ use super::backward_references::{
     H9_BLOCK_BITS, H9_BLOCK_SIZE, H9_BUCKET_BITS, H9_NUM_LAST_DISTANCES_TO_CHECK,
 };
 use super::bit_cost::{BitsEntropy, ShannonEntropy};
-#[allow(unused_imports)]
-use super::block_split::BlockSplit;
-#[allow(unused_imports)]
 use super::brotli_bit_stream::{
-    BrotliBuildAndStoreHuffmanTreeFast, BrotliStoreHuffmanTree, BrotliStoreMetaBlock,
-    BrotliStoreMetaBlockFast, BrotliStoreMetaBlockTrivial, BrotliStoreUncompressedMetaBlock,
-    BrotliWriteEmptyLastMetaBlock, BrotliWriteMetadataMetaBlock, JumpToByteBoundary,
+    BrotliStoreMetaBlock, BrotliStoreMetaBlockFast, BrotliStoreMetaBlockTrivial,
+    BrotliStoreUncompressedMetaBlock, BrotliWriteEmptyLastMetaBlock, BrotliWriteMetadataMetaBlock,
     MetaBlockSplit, RecoderState,
 };
 use super::combined_alloc::BrotliAlloc;
+use super::command::{BrotliDistanceParams, Command, GetLengthCode};
+use super::compress_fragment::BrotliCompressFragmentFast;
+use super::compress_fragment_two_pass::{BrotliCompressFragmentTwoPass, BrotliWriteBits};
 use super::constants::{
     BROTLI_CONTEXT, BROTLI_CONTEXT_LUT, BROTLI_MAX_NDIRECT, BROTLI_MAX_NPOSTFIX,
     BROTLI_NUM_HISTOGRAM_DISTANCE_SYMBOLS, BROTLI_WINDOW_GAP,
 };
 use super::hash_to_binary_tree::InitializeH10;
-use super::interface;
-pub use super::parameters::BrotliEncoderParameter;
-use alloc::Allocator;
-
-use super::super::alloc::{SliceWrapper, SliceWrapperMut};
-use super::command::{BrotliDistanceParams, Command, GetLengthCode};
-use super::compress_fragment::BrotliCompressFragmentFast;
-use super::compress_fragment_two_pass::{BrotliCompressFragmentTwoPass, BrotliWriteBits};
-#[allow(unused_imports)]
-use super::entropy_encode::{
-    BrotliConvertBitDepthsToSymbols, BrotliCreateHuffmanTree, HuffmanTree,
-};
 use super::histogram::{
     ContextType, CostAccessors, HistogramCommand, HistogramDistance, HistogramLiteral,
 };
+use super::interface;
 use super::metablock::{
     BrotliBuildMetaBlock, BrotliBuildMetaBlockGreedy, BrotliInitDistanceParams,
     BrotliOptimizeHistograms,
 };
+pub use super::parameters::BrotliEncoderParameter;
 use super::static_dict::{kNumDistanceCacheEntries, BrotliGetDictionary};
 use super::utf8_util::BrotliIsMostlyUTF8;
 use super::util::Log2FloorNonZero;
-use core::cmp::{max, min};
-use enc::input_pair::InputReferenceMut;
+
 //fn BrotliCreateHqZopfliBackwardReferences(m: &mut [MemoryManager],
 //                                          dictionary: &[BrotliDictionary],
 //                                          num_bytes: usize,
diff --git a/src/enc/entropy_encode.rs b/src/enc/entropy_encode.rs
index 381831ae..98257a1f 100644
--- a/src/enc/entropy_encode.rs
+++ b/src/enc/entropy_encode.rs
@@ -1,3 +1,5 @@
+#![allow(dead_code)]
+
 /* Copyright 2010 Google Inc. All Rights Reserved.
 
    Distributed under MIT license.
@@ -5,7 +7,6 @@
 */
 
 /* Entropy encoding (Huffman) utilities. */
-#![allow(dead_code)]
 use core::cmp::max;
 
 #[derive(Clone, Copy, Default)]
diff --git a/src/enc/find_stride.rs b/src/enc/find_stride.rs
index 56213ad6..1cd12360 100644
--- a/src/enc/find_stride.rs
+++ b/src/enc/find_stride.rs
@@ -1,10 +1,11 @@
+use core::cmp::{max, min};
+use core::ops::{Index, IndexMut, Range};
+
+use super::super::alloc;
 use super::super::alloc::{SliceWrapper, SliceWrapperMut};
 use super::input_pair::{InputPair, InputReference};
 use super::interface;
 use super::util::FastLog2;
-use core::cmp::{max, min};
-
-use core::ops::{Index, IndexMut, Range};
 // float32 doesn't have enough resolution for blocks of data more than 3.5 megs
 pub type floatY = f64;
 // the cost of storing a particular population of data including the approx
diff --git a/src/enc/histogram.rs b/src/enc/histogram.rs
index 0992c8a9..591f0644 100644
--- a/src/enc/histogram.rs
+++ b/src/enc/histogram.rs
@@ -1,11 +1,14 @@
 #![allow(dead_code)]
 
+use core;
+use core::cmp::min;
+
+use super::super::alloc;
 use super::super::alloc::{SliceWrapper, SliceWrapperMut};
 use super::block_split::BlockSplit;
 use super::command::Command;
 use super::constants::{kSigned3BitContextLookup, kUTF8ContextLookup};
 use super::vectorization::Mem256i;
-use core::cmp::min;
 static kBrotliMinWindowBits: i32 = 10i32;
 
 static kBrotliMaxWindowBits: i32 = 24i32;
diff --git a/src/enc/input_pair.rs b/src/enc/input_pair.rs
index a32d58d1..828b9ea0 100644
--- a/src/enc/input_pair.rs
+++ b/src/enc/input_pair.rs
@@ -1,7 +1,8 @@
-use super::super::alloc::SliceWrapper;
-use super::super::alloc::SliceWrapperMut;
-use super::interface::Freezable;
+use core;
 use core::cmp::min;
+
+use super::super::alloc::{SliceWrapper, SliceWrapperMut};
+use super::interface::Freezable;
 #[derive(Copy, Clone, Default, Debug)]
 pub struct InputReference<'a> {
     pub data: &'a [u8],
diff --git a/src/enc/interface.rs b/src/enc/interface.rs
index 8196397e..41ac6ea5 100644
--- a/src/enc/interface.rs
+++ b/src/enc/interface.rs
@@ -1,11 +1,13 @@
-use super::histogram;
-pub use super::input_pair::{InputPair, InputReference, InputReferenceMut};
 use alloc::{Allocator, SliceWrapper, SliceWrapperMut};
-#[allow(unused_imports)] // right now just used in feature flag
 use core;
+
+use super::histogram;
+pub use super::input_pair::{InputPair, InputReference, InputReferenceMut};
+
 #[derive(Debug, Copy, Clone, Default)]
 pub struct BlockSwitch(pub u8);
-// Commands that can instantiate as a no-op should implement this.
+
+/// Commands that can instantiate as a no-op should implement this.
 pub trait Nop<T> {
     fn nop() -> T;
 }
@@ -761,8 +763,7 @@ pub fn u8_to_speed(data: u8) -> u16 {
 }
 #[cfg(test)]
 mod test {
-    use super::speed_to_u8;
-    use super::u8_to_speed;
+    use super::{speed_to_u8, u8_to_speed};
     fn tst_u8_to_speed(data: u16) {
         assert_eq!(u8_to_speed(speed_to_u8(data)), data);
     }
diff --git a/src/enc/literal_cost.rs b/src/enc/literal_cost.rs
index a6c8ea02..890497b2 100644
--- a/src/enc/literal_cost.rs
+++ b/src/enc/literal_cost.rs
@@ -1,7 +1,9 @@
 #![allow(dead_code)]
+
+use core::cmp::min;
+
 use super::utf8_util::BrotliIsMostlyUTF8;
 use super::util::FastLog2f64;
-use core::cmp::min;
 
 static kMinUTF8Ratio: super::util::floatX = 0.75 as super::util::floatX;
 
diff --git a/src/enc/metablock.rs b/src/enc/metablock.rs
index aaf33a90..ee667506 100644
--- a/src/enc/metablock.rs
+++ b/src/enc/metablock.rs
@@ -1,4 +1,9 @@
 #![allow(dead_code)]
+
+use core;
+use core::cmp::{max, min};
+
+use super::super::alloc;
 use super::super::alloc::{Allocator, SliceWrapper, SliceWrapperMut};
 use super::backward_references::BrotliEncoderParams;
 use super::bit_cost::{BitsEntropy, BrotliPopulationCost};
@@ -19,7 +24,6 @@ use super::histogram::{
     HistogramAddHistogram, HistogramAddItem, HistogramClear, HistogramCommand, HistogramDistance,
     HistogramLiteral,
 };
-use core::cmp::{max, min};
 
 pub fn BrotliInitDistanceParams(params: &mut BrotliEncoderParams, npostfix: u32, ndirect: u32) {
     let dist_params = &mut params.dist;
diff --git a/src/enc/mod.rs b/src/enc/mod.rs
index bebf7bd5..7f114429 100644
--- a/src/enc/mod.rs
+++ b/src/enc/mod.rs
@@ -1,95 +1,95 @@
-#![cfg_attr(not(feature = "std"), allow(unused_imports))]
 #[macro_use]
 pub mod vectorization;
 pub mod backward_references;
 pub mod bit_cost;
 pub mod block_split;
+pub mod block_splitter;
 pub mod brotli_bit_stream;
 pub mod cluster;
 pub mod combined_alloc;
 pub mod command;
+mod compat;
+pub mod compress_fragment;
+pub mod compress_fragment_two_pass;
 pub mod constants;
+pub mod context_map_entropy;
 pub mod dictionary_hash;
+pub mod encode;
 pub mod entropy_encode;
 pub mod fast_log;
+pub mod find_stride;
+pub mod fixed_queue;
 pub mod histogram;
 pub mod input_pair;
-pub mod literal_cost;
-pub mod static_dict;
-pub mod static_dict_lut;
-pub mod utf8_util;
-pub mod util;
-pub use self::backward_references::hash_to_binary_tree;
-pub use self::backward_references::hq as backward_references_hq;
-pub mod block_splitter;
-pub mod compress_fragment;
-pub mod compress_fragment_two_pass;
-pub mod context_map_entropy;
-pub mod encode;
-pub mod find_stride;
 pub mod interface;
 pub mod ir_interpret;
+pub mod literal_cost;
 pub mod metablock;
+pub mod multithreading;
+mod parameters;
 pub mod pdf;
 pub mod prior_eval;
 pub mod reader;
-pub mod stride_eval;
-pub mod writer;
-pub use self::combined_alloc::{BrotliAlloc, CombiningAllocator};
-mod compat;
-pub mod fixed_queue;
-pub mod multithreading;
 pub mod singlethreading;
-pub mod threading;
-pub mod worker_pool;
-#[cfg(feature = "simd")]
-pub type s16 = core::simd::i16x16;
-#[cfg(feature = "simd")]
-pub type v8 = core::simd::f32x8;
-#[cfg(feature = "simd")]
-pub type s8 = core::simd::i32x8;
-#[cfg(not(feature = "simd"))]
-pub type s16 = compat::Compat16x16;
-#[cfg(not(feature = "simd"))]
-pub type v8 = compat::CompatF8;
-#[cfg(not(feature = "simd"))]
-pub type s8 = compat::Compat32x8;
-
-mod parameters;
+pub mod static_dict;
+pub mod static_dict_lut;
+pub mod stride_eval;
 mod test;
+pub mod threading;
+pub mod utf8_util;
+pub mod util;
 mod weights;
-pub use self::backward_references::{BrotliEncoderParams, UnionHasher};
-use self::encode::{BrotliEncoderDestroyInstance, BrotliEncoderOperation};
-pub use self::encode::{
-    BrotliEncoderInitParams, BrotliEncoderMaxCompressedSize, BrotliEncoderMaxCompressedSizeMulti,
-};
-pub use self::hash_to_binary_tree::ZopfliNode;
-pub use self::interface::StaticCommand;
-pub use self::pdf::PDF;
-pub use self::util::floatX;
-pub use self::vectorization::{v256, v256i, Mem256f};
-use brotli_decompressor::{CustomRead, CustomWrite};
-pub use interface::{InputPair, InputReference, InputReferenceMut};
+pub mod worker_pool;
+pub mod writer;
 
 pub use alloc::{AllocatedStackMemory, Allocator, SliceWrapper, SliceWrapperMut, StackAllocator};
 #[cfg(feature = "std")]
-pub use alloc_stdlib::StandardAlloc;
-#[cfg(feature = "std")]
 use std::io;
 #[cfg(feature = "std")]
 use std::io::{Error, ErrorKind, Read, Write};
 
+#[cfg(feature = "std")]
+pub use alloc_stdlib::StandardAlloc;
+use brotli_decompressor::{CustomRead, CustomWrite};
 #[cfg(feature = "std")]
 pub use brotli_decompressor::{IntoIoReader, IoReaderWrapper, IoWriterWrapper};
 use enc::encode::BrotliEncoderStateStruct;
+pub use interface::{InputPair, InputReference, InputReferenceMut};
 
+pub use self::backward_references::{
+    hash_to_binary_tree, hq as backward_references_hq, BrotliEncoderParams, UnionHasher,
+};
+pub use self::combined_alloc::{BrotliAlloc, CombiningAllocator};
+use self::encode::{BrotliEncoderDestroyInstance, BrotliEncoderOperation};
+pub use self::encode::{
+    BrotliEncoderInitParams, BrotliEncoderMaxCompressedSize, BrotliEncoderMaxCompressedSizeMulti,
+};
+pub use self::hash_to_binary_tree::ZopfliNode;
+pub use self::interface::StaticCommand;
+pub use self::pdf::PDF;
 #[cfg(not(feature = "std"))]
 pub use self::singlethreading::{compress_worker_pool, new_work_pool, WorkerPool};
 pub use self::threading::{
     BatchSpawnableLite, BrotliEncoderThreadError, CompressionThreadResult, Owned, SendAlloc,
 };
+pub use self::util::floatX;
+pub use self::vectorization::{v256, v256i, Mem256f};
 #[cfg(feature = "std")]
 pub use self::worker_pool::{compress_worker_pool, new_work_pool, WorkerPool};
+
+#[cfg(feature = "simd")]
+pub type s16 = core::simd::i16x16;
+#[cfg(feature = "simd")]
+pub type v8 = core::simd::f32x8;
+#[cfg(feature = "simd")]
+pub type s8 = core::simd::i32x8;
+#[cfg(not(feature = "simd"))]
+pub type s16 = compat::Compat16x16;
+#[cfg(not(feature = "simd"))]
+pub type v8 = compat::CompatF8;
+#[cfg(not(feature = "simd"))]
+pub type s8 = compat::Compat32x8;
+
 #[cfg(feature = "std")]
 pub fn compress_multi<
     Alloc: BrotliAlloc + Send + 'static,
diff --git a/src/enc/multithreading.rs b/src/enc/multithreading.rs
index b90d8db0..cef99f26 100644
--- a/src/enc/multithreading.rs
+++ b/src/enc/multithreading.rs
@@ -1,20 +1,20 @@
 #![cfg(feature = "std")]
+
 use alloc::{Allocator, SliceWrapper};
 use core::marker::PhantomData;
 use core::mem;
+use std;
+// in-place thread create
+use std::sync::RwLock;
+use std::thread::JoinHandle;
+
 use enc::backward_references::UnionHasher;
 use enc::threading::{
     AnyBoxConstructor, BatchSpawnable, BatchSpawnableLite, BrotliEncoderThreadError, CompressMulti,
     CompressionThreadResult, InternalOwned, InternalSendAlloc, Joinable, Owned, OwnedRetriever,
     PoisonedThreadError, SendAlloc,
 };
-use enc::BrotliAlloc;
-use enc::BrotliEncoderParams;
-use std::thread::JoinHandle;
-
-// in-place thread create
-
-use std::sync::RwLock;
+use enc::{BrotliAlloc, BrotliEncoderParams};
 
 pub struct MultiThreadedJoinable<T: Send + 'static, U: Send + 'static>(
     JoinHandle<T>,
@@ -31,6 +31,7 @@ impl<T: Send + 'static, U: Send + 'static + AnyBoxConstructor> Joinable<T, U>
         }
     }
 }
+
 pub struct MultiThreadedOwnedRetriever<U: Send + 'static>(RwLock<U>);
 
 impl<U: Send + 'static> OwnedRetriever<U> for MultiThreadedOwnedRetriever<U> {
diff --git a/src/enc/prior_eval.rs b/src/enc/prior_eval.rs
index 29f15ea9..a7407586 100644
--- a/src/enc/prior_eval.rs
+++ b/src/enc/prior_eval.rs
@@ -1,14 +1,15 @@
+use core;
+use core::cmp::min;
+#[cfg(feature = "simd")]
+use core::simd::prelude::SimdPartialOrd;
+
+use super::super::alloc;
 use super::super::alloc::{Allocator, SliceWrapper, SliceWrapperMut};
 use super::backward_references::BrotliEncoderParams;
-use super::find_stride;
 use super::input_pair::{InputPair, InputReference, InputReferenceMut};
-use super::interface;
 use super::ir_interpret::{push_base, IRInterpreter};
 use super::util::{floatX, FastLog2u16};
-use super::{s16, v8};
-use core::cmp::min;
-#[cfg(feature = "simd")]
-use core::simd::prelude::SimdPartialOrd;
+use super::{find_stride, interface, s16, v8};
 
 // the high nibble, followed by the low nibbles
 pub const CONTEXT_MAP_PRIOR_SIZE: usize = 256 * 17;
diff --git a/src/enc/reader.rs b/src/enc/reader.rs
index 81e2fa77..389e5acd 100644
--- a/src/enc/reader.rs
+++ b/src/enc/reader.rs
@@ -1,4 +1,14 @@
-#![cfg_attr(not(feature = "std"), allow(unused_imports))]
+use alloc::{Allocator, SliceWrapperMut};
+#[cfg(feature = "std")]
+use std::io;
+#[cfg(feature = "std")]
+use std::io::{Error, ErrorKind, Read};
+
+#[cfg(feature = "std")]
+pub use alloc_stdlib::StandardAlloc;
+use brotli_decompressor::CustomRead;
+#[cfg(feature = "std")]
+pub use brotli_decompressor::{IntoIoReader, IoReaderWrapper, IoWriterWrapper};
 
 use super::backward_references::BrotliEncoderParams;
 use super::combined_alloc::BrotliAlloc;
@@ -7,19 +17,6 @@ use super::encode::{
     BrotliEncoderStateStruct,
 };
 use super::interface;
-use brotli_decompressor::CustomRead;
-
-#[cfg(feature = "std")]
-pub use brotli_decompressor::{IntoIoReader, IoReaderWrapper, IoWriterWrapper};
-
-pub use alloc::{AllocatedStackMemory, Allocator, SliceWrapper, SliceWrapperMut, StackAllocator};
-#[cfg(feature = "std")]
-pub use alloc_stdlib::StandardAlloc;
-#[cfg(feature = "std")]
-use std::io;
-
-#[cfg(feature = "std")]
-use std::io::{Error, ErrorKind, Read};
 
 #[cfg(feature = "std")]
 pub struct CompressorReaderCustomAlloc<R: Read, BufferType: SliceWrapperMut<u8>, Alloc: BrotliAlloc>(
diff --git a/src/enc/singlethreading.rs b/src/enc/singlethreading.rs
index a3ed723f..22815e77 100644
--- a/src/enc/singlethreading.rs
+++ b/src/enc/singlethreading.rs
@@ -1,14 +1,17 @@
-use super::backward_references::UnionHasher;
 use alloc::{Allocator, SliceWrapper};
 use core::marker::PhantomData;
 use core::mem;
+#[cfg(feature = "std")]
+use std;
+
 use enc::threading::{
     BatchSpawnable, BatchSpawnableLite, BrotliEncoderThreadError, CompressMulti,
     CompressionThreadResult, InternalOwned, InternalSendAlloc, Joinable, Owned, OwnedRetriever,
     PoisonedThreadError, SendAlloc,
 };
-use enc::BrotliAlloc;
-use enc::BrotliEncoderParams;
+use enc::{BrotliAlloc, BrotliEncoderParams};
+
+use super::backward_references::UnionHasher;
 
 pub struct SingleThreadedJoinable<T: Send + 'static, U: Send + 'static> {
     result: Result<T, U>,
diff --git a/src/enc/static_dict_lut.rs b/src/enc/static_dict_lut.rs
index e581dca2..ac8ac352 100644
--- a/src/enc/static_dict_lut.rs
+++ b/src/enc/static_dict_lut.rs
@@ -1,4 +1,5 @@
 #![allow(dead_code)]
+
 pub static kInvalidMatch: u32 = 0x0fff_ffff;
 
 pub static kDictNumBits: i32 = 15;
diff --git a/src/enc/stride_eval.rs b/src/enc/stride_eval.rs
index c7e4da55..ef05660b 100644
--- a/src/enc/stride_eval.rs
+++ b/src/enc/stride_eval.rs
@@ -1,3 +1,6 @@
+use core;
+
+use super::super::alloc;
 use super::super::alloc::{Allocator, SliceWrapper, SliceWrapperMut};
 use super::backward_references::BrotliEncoderParams;
 use super::input_pair::{InputPair, InputReference, InputReferenceMut};
diff --git a/src/enc/threading.rs b/src/enc/threading.rs
index 17aaecf1..a7c31f75 100644
--- a/src/enc/threading.rs
+++ b/src/enc/threading.rs
@@ -1,16 +1,19 @@
+use alloc::{Allocator, SliceWrapper, SliceWrapperMut};
+use core::marker::PhantomData;
+use core::ops::Range;
+use core::{any, mem};
+#[cfg(feature = "std")]
+use std;
+
+use concat::{BroCatli, BroCatliResult};
+use enc::encode::BrotliEncoderStateStruct;
+
 use super::backward_references::{AnyHasher, BrotliEncoderParams, CloneWithAlloc, UnionHasher};
 use super::encode::{
     BrotliEncoderDestroyInstance, BrotliEncoderMaxCompressedSize, BrotliEncoderOperation,
     HasherSetup, SanitizeParams,
 };
 use super::BrotliAlloc;
-use alloc::{Allocator, SliceWrapper, SliceWrapperMut};
-use concat::{BroCatli, BroCatliResult};
-use core::any;
-use core::marker::PhantomData;
-use core::mem;
-use core::ops::Range;
-use enc::encode::BrotliEncoderStateStruct;
 
 pub type PoisonedThreadError = ();
 
diff --git a/src/enc/utf8_util.rs b/src/enc/utf8_util.rs
index c772ca01..b9fc1836 100644
--- a/src/enc/utf8_util.rs
+++ b/src/enc/utf8_util.rs
@@ -1,4 +1,5 @@
 #![allow(dead_code)]
+
 static kMinUTF8Ratio: super::util::floatX = 0.75 as super::util::floatX;
 
 fn BrotliParseAsUTF8(symbol: &mut i32, input: &[u8], size: usize) -> usize {
diff --git a/src/enc/worker_pool.rs b/src/enc/worker_pool.rs
index c7e1ca06..839c766f 100644
--- a/src/enc/worker_pool.rs
+++ b/src/enc/worker_pool.rs
@@ -1,19 +1,19 @@
 #![cfg(feature = "std")]
-use core::mem;
 
 use alloc::{Allocator, SliceWrapper};
+use core::mem;
+use std;
+// in-place thread create
+use std::sync::RwLock;
+use std::sync::{Arc, Condvar, Mutex};
+
 use enc::backward_references::UnionHasher;
 use enc::fixed_queue::{FixedQueue, MAX_THREADS};
 use enc::threading::{
     BatchSpawnableLite, BrotliEncoderThreadError, CompressMulti, CompressionThreadResult,
     InternalOwned, InternalSendAlloc, Joinable, Owned, SendAlloc,
 };
-use enc::BrotliAlloc;
-use enc::BrotliEncoderParams;
-use std::sync::{Arc, Condvar, Mutex};
-// in-place thread create
-
-use std::sync::RwLock;
+use enc::{BrotliAlloc, BrotliEncoderParams};
 
 struct JobReply<T: Send + 'static> {
     result: T,
diff --git a/src/enc/writer.rs b/src/enc/writer.rs
index bde64b69..d4c5aec4 100644
--- a/src/enc/writer.rs
+++ b/src/enc/writer.rs
@@ -1,4 +1,15 @@
-#![cfg_attr(not(feature = "std"), allow(unused_imports))]
+use alloc::{Allocator, SliceWrapperMut};
+#[cfg(feature = "std")]
+use std::io;
+#[cfg(feature = "std")]
+use std::io::{Error, ErrorKind, Write};
+
+#[cfg(feature = "std")]
+pub use alloc_stdlib::StandardAlloc;
+use brotli_decompressor::CustomWrite;
+#[cfg(feature = "std")]
+pub use brotli_decompressor::{IntoIoWriter, IoWriterWrapper};
+
 use super::backward_references::BrotliEncoderParams;
 use super::combined_alloc::BrotliAlloc;
 use super::encode::{
@@ -6,18 +17,6 @@ use super::encode::{
     BrotliEncoderStateStruct,
 };
 use super::interface;
-pub use alloc::{AllocatedStackMemory, Allocator, SliceWrapper, SliceWrapperMut, StackAllocator};
-#[cfg(feature = "std")]
-pub use alloc_stdlib::StandardAlloc;
-use brotli_decompressor::CustomWrite;
-#[cfg(feature = "std")]
-pub use brotli_decompressor::{IntoIoWriter, IoWriterWrapper};
-
-#[cfg(feature = "std")]
-use std::io;
-
-#[cfg(feature = "std")]
-use std::io::{Error, ErrorKind, Write};
 
 #[cfg(feature = "std")]
 pub struct CompressorWriterCustomAlloc<
diff --git a/src/ffi/broccoli.rs b/src/ffi/broccoli.rs
index f75915f2..b9257050 100644
--- a/src/ffi/broccoli.rs
+++ b/src/ffi/broccoli.rs
@@ -1,8 +1,9 @@
+use core;
+
 pub use brotli_decompressor::ffi::interface::c_void;
 use brotli_decompressor::ffi::{slice_from_raw_parts_or_nil, slice_from_raw_parts_or_nil_mut};
 use concat::BroCatli;
 pub use concat::BroCatliResult;
-use core;
 pub type BroccoliResult = BroCatliResult;
 // a tool to concatenate brotli files together
 
diff --git a/src/ffi/compressor.rs b/src/ffi/compressor.rs
index 230b2b8f..3c3c9724 100644
--- a/src/ffi/compressor.rs
+++ b/src/ffi/compressor.rs
@@ -1,20 +1,22 @@
 #![cfg(not(feature = "safe"))]
 
+use core;
 #[cfg(feature = "std")]
 use std::io::Write;
 #[cfg(feature = "std")]
 use std::{io, panic, thread};
 
-use super::alloc_util::BrotliSubclassableAllocator;
-use brotli_decompressor::ffi::alloc_util;
 use brotli_decompressor::ffi::alloc_util::SubclassableAllocator;
 use brotli_decompressor::ffi::interface::{
     brotli_alloc_func, brotli_free_func, c_void, CAllocator,
 };
-use brotli_decompressor::ffi::{slice_from_raw_parts_or_nil, slice_from_raw_parts_or_nil_mut};
-use core;
+use brotli_decompressor::ffi::{
+    alloc_util, slice_from_raw_parts_or_nil, slice_from_raw_parts_or_nil_mut,
+};
 use enc::encode::BrotliEncoderStateStruct;
 
+use super::alloc_util::BrotliSubclassableAllocator;
+
 #[repr(C)]
 pub enum BrotliEncoderOperation {
     BROTLI_OPERATION_PROCESS = 0,
diff --git a/src/ffi/decompressor.rs b/src/ffi/decompressor.rs
index 8f0c6429..089d700e 100644
--- a/src/ffi/decompressor.rs
+++ b/src/ffi/decompressor.rs
@@ -1,6 +1,5 @@
-pub use brotli_decompressor::ffi;
 pub use brotli_decompressor::ffi::interface::{brotli_alloc_func, brotli_free_func, c_void};
-pub use brotli_decompressor::{BrotliDecoderReturnInfo, HuffmanCode};
+pub use brotli_decompressor::{ffi, BrotliDecoderReturnInfo, HuffmanCode};
 
 pub unsafe extern "C" fn CBrotliDecoderCreateInstance(
     alloc_func: brotli_alloc_func,
diff --git a/src/ffi/multicompress/mod.rs b/src/ffi/multicompress/mod.rs
index 70aec521..79174fb6 100644
--- a/src/ffi/multicompress/mod.rs
+++ b/src/ffi/multicompress/mod.rs
@@ -4,24 +4,24 @@ use std::io::Write;
 #[cfg(feature = "std")]
 use std::{io, panic, thread};
 mod test;
-use super::compressor;
-#[allow(unused_imports)]
-use brotli_decompressor;
+use alloc::SliceWrapper;
+use core::cmp::min;
+
 use brotli_decompressor::ffi::alloc_util::SubclassableAllocator;
 use brotli_decompressor::ffi::interface::{
     brotli_alloc_func, brotli_free_func, c_void, CAllocator,
 };
 use brotli_decompressor::ffi::{slice_from_raw_parts_or_nil, slice_from_raw_parts_or_nil_mut};
-use core;
-use core::cmp::min;
-use enc::encode::{BrotliEncoderOperation, BrotliEncoderStateStruct};
-
-use super::alloc_util::BrotliSubclassableAllocator;
-use alloc::SliceWrapper;
-use enc;
 use enc::backward_references::{BrotliEncoderParams, UnionHasher};
-use enc::encode::{set_parameter, BrotliEncoderParameter};
+use enc::encode::{
+    set_parameter, BrotliEncoderOperation, BrotliEncoderParameter, BrotliEncoderStateStruct,
+};
 use enc::threading::{Owned, SendAlloc};
+use {brotli_decompressor, core, enc};
+
+use super::alloc_util::BrotliSubclassableAllocator;
+use super::compressor;
+
 pub const MAX_THREADS: usize = 16;
 
 struct SliceRef<'a>(&'a [u8]);
@@ -43,6 +43,7 @@ macro_rules! make_send_alloc {
         )
     };
 }
+
 #[no_mangle]
 pub extern "C" fn BrotliEncoderMaxCompressedSizeMulti(
     input_size: usize,
diff --git a/src/lib.rs b/src/lib.rs
index bf05e2b9..542bb5c5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -10,81 +10,68 @@
     feature = "no-stdlib-ffi-binding",
     cfg_attr(not(feature = "std"), feature(lang_items))
 )]
+
 #[macro_use]
 // <-- for debugging, remove xprintln from bit_reader and replace with println
 #[cfg(feature = "std")]
 extern crate std;
+extern crate alloc_no_stdlib as alloc;
 #[cfg(feature = "std")]
 extern crate alloc_stdlib;
-#[allow(unused_imports)]
-#[macro_use]
-extern crate alloc_no_stdlib as alloc;
 extern crate brotli_decompressor;
+
+pub mod concat;
+pub mod enc;
+#[cfg(feature = "ffi-api")]
+pub mod ffi;
+
 pub use alloc::{AllocatedStackMemory, Allocator, SliceWrapper, SliceWrapperMut, StackAllocator};
-pub const VERSION: u8 = 1;
+
 #[cfg(feature = "std")]
 pub use alloc_stdlib::HeapAlloc;
-pub mod enc;
-pub use self::enc::combined_alloc::CombiningAllocator;
-pub mod concat;
-pub use brotli_decompressor::dictionary;
-pub use brotli_decompressor::reader;
+#[cfg(feature = "std")]
+pub use brotli_decompressor::copy_from_to;
+pub use brotli_decompressor::io_wrappers::{CustomRead, CustomWrite};
+#[cfg(feature = "std")]
+pub use brotli_decompressor::io_wrappers::{IntoIoReader, IoReaderWrapper, IoWriterWrapper};
 #[cfg(feature = "std")]
 pub use brotli_decompressor::reader::Decompressor;
 pub use brotli_decompressor::reader::DecompressorCustomIo;
-pub use brotli_decompressor::transform;
 pub use brotli_decompressor::transform::TransformDictionaryWord;
-pub use brotli_decompressor::writer;
-pub use brotli_decompressor::BrotliState;
-pub use brotli_decompressor::HuffmanCode; // so we can make custom allocator for decompression
-
-pub use brotli_decompressor::writer::DecompressorWriterCustomIo;
-
 #[cfg(feature = "std")]
 pub use brotli_decompressor::writer::DecompressorWriter;
-
-pub use brotli_decompressor::io_wrappers::{CustomRead, CustomWrite};
-
+pub use brotli_decompressor::writer::DecompressorWriterCustomIo;
 #[cfg(feature = "std")]
-pub use brotli_decompressor::io_wrappers::{IntoIoReader, IoReaderWrapper, IoWriterWrapper};
-pub use enc::input_pair::InputPair;
-pub use enc::input_pair::InputReference;
-pub use enc::input_pair::InputReferenceMut;
-pub use enc::interface;
-pub use enc::interface::SliceOffset;
-#[cfg(feature = "ffi-api")]
-pub mod ffi;
-// interface
-// pub fn BrotliDecompressStream(mut available_in: &mut usize,
-//                               input_offset: &mut usize,
-//                               input: &[u8],
-//                               mut available_out: &mut usize,
-//                               mut output_offset: &mut usize,
-//                               mut output: &mut [u8],
-//                               mut total_out: &mut usize,
-//                               mut s: &mut BrotliState<AllocU8, AllocU32, AllocHC>);
-
-pub use brotli_decompressor::{BrotliDecompressStream, BrotliResult};
+pub use brotli_decompressor::BrotliDecompress;
 #[cfg(feature = "std")]
-pub use enc::{BrotliCompress, BrotliCompressCustomAlloc};
-pub use enc::{BrotliCompressCustomIo, BrotliCompressCustomIoCustomDict};
-
+pub use brotli_decompressor::BrotliDecompressCustomAlloc;
+pub use brotli_decompressor::HuffmanCode; // so we can make custom allocator for decompression
+pub use brotli_decompressor::{
+    dictionary, reader, transform, writer, BrotliDecompressCustomIo,
+    BrotliDecompressCustomIoCustomDict, BrotliDecompressStream, BrotliResult, BrotliState,
+};
+pub use enc::input_pair::{InputPair, InputReference, InputReferenceMut};
+pub use enc::interface::SliceOffset;
 #[cfg(feature = "std")]
 pub use enc::reader::CompressorReader;
 pub use enc::reader::CompressorReaderCustomIo;
-
 #[cfg(feature = "std")]
 pub use enc::writer::CompressorWriter;
 pub use enc::writer::CompressorWriterCustomIo;
-
+pub use enc::{interface, BrotliCompressCustomIo, BrotliCompressCustomIoCustomDict};
 #[cfg(feature = "std")]
-pub use brotli_decompressor::BrotliDecompress;
+pub use enc::{BrotliCompress, BrotliCompressCustomAlloc};
 
-#[cfg(feature = "std")]
-pub use brotli_decompressor::BrotliDecompressCustomAlloc;
+pub use self::enc::combined_alloc::CombiningAllocator;
 
-pub use brotli_decompressor::BrotliDecompressCustomIo;
-pub use brotli_decompressor::BrotliDecompressCustomIoCustomDict;
+pub const VERSION: u8 = 1;
 
-#[cfg(feature = "std")]
-pub use brotli_decompressor::copy_from_to;
+// interface
+// pub fn BrotliDecompressStream(mut available_in: &mut usize,
+//                               input_offset: &mut usize,
+//                               input: &[u8],
+//                               mut available_out: &mut usize,
+//                               mut output_offset: &mut usize,
+//                               mut output: &mut [u8],
+//                               mut total_out: &mut usize,
+//                               mut s: &mut BrotliState<AllocU8, AllocU32, AllocHC>);


Test patch:
diff --git a/src/bin/integration_tests.rs b/src/bin/integration_tests.rs
index 46a32960..dc8b0272 100644
--- a/src/bin/integration_tests.rs
+++ b/src/bin/integration_tests.rs
@@ -1,19 +1,10 @@
 #![cfg(test)]
 #![allow(non_upper_case_globals)]
 #![allow(dead_code)]
+
 extern crate brotli_decompressor;
 extern crate core;
-#[allow(unused_imports)]
-use super::alloc_no_stdlib::{Allocator, SliceWrapper, SliceWrapperMut};
-use super::brotli::BrotliResult;
-use super::brotli::BrotliState;
-#[cfg(feature = "std")]
-use super::brotli::{CompressorReader, CompressorWriter};
-#[cfg(feature = "std")]
-use super::brotli_decompressor::{Decompressor, DecompressorWriter};
-use super::HeapAllocator;
-use super::Rebox;
-use brotli::BrotliDecompressStream;
+
 use core::cmp::min;
 use std::io;
 #[cfg(feature = "std")]
@@ -22,6 +13,16 @@ use std::time::Duration;
 #[cfg(not(feature = "disable-timer"))]
 use std::time::SystemTime;
 
+use brotli::BrotliDecompressStream;
+
+use super::alloc_no_stdlib::{Allocator, SliceWrapper, SliceWrapperMut};
+use super::brotli::{BrotliResult, BrotliState};
+#[cfg(feature = "std")]
+use super::brotli::{CompressorReader, CompressorWriter};
+#[cfg(feature = "std")]
+use super::brotli_decompressor::{Decompressor, DecompressorWriter};
+use super::{HeapAllocator, Rebox};
+
 #[cfg(feature = "benchmark")]
 extern crate test;
 #[cfg(feature = "benchmark")]
diff --git a/src/bin/test_broccoli.rs b/src/bin/test_broccoli.rs
index e1701ecc..6a781b7c 100644
--- a/src/bin/test_broccoli.rs
+++ b/src/bin/test_broccoli.rs
@@ -1,13 +1,19 @@
 #![cfg(test)]
 #![allow(non_upper_case_globals)]
 #![allow(dead_code)]
+
 extern crate brotli_decompressor;
 extern crate core;
+
+use core::cmp::{max, min};
+
+use brotli_decompressor::{CustomRead, CustomWrite};
+
 use super::brotli::concat::{BroCatli, BroCatliResult};
 use super::brotli::enc::BrotliEncoderParams;
 use super::integration_tests::UnlimitedBuffer;
-use brotli_decompressor::{CustomRead, CustomWrite};
-use core::cmp::{max, min};
+use super::Rebox;
+
 static RANDOM_THEN_UNICODE: &[u8] = include_bytes!("../../testdata/random_then_unicode");
 static ALICE: &[u8] = include_bytes!("../../testdata/alice29.txt");
 static UKKONOOA: &[u8] = include_bytes!("../../testdata/ukkonooa");
@@ -18,7 +24,7 @@ static RANDOM10K: &[u8] = include_bytes!("../../testdata/random_org_10k.bin");
 static RANDOMTHENUNICODE: &[u8] = include_bytes!("../../testdata/random_then_unicode");
 static QUICKFOX: &[u8] = include_bytes!("../../testdata/quickfox_repeated");
 static EMPTY: &[u8] = &[];
-use super::Rebox;
+
 fn concat(
     files: &mut [UnlimitedBuffer],
     brotli_files: &mut [UnlimitedBuffer],
diff --git a/src/bin/test_custom_dict.rs b/src/bin/test_custom_dict.rs
index f81ebf6c..4b9705cc 100644
--- a/src/bin/test_custom_dict.rs
+++ b/src/bin/test_custom_dict.rs
@@ -1,15 +1,19 @@
 #![cfg(test)]
 #![allow(non_upper_case_globals)]
 #![allow(dead_code)]
+
 extern crate brotli_decompressor;
 extern crate core;
+
+use std::io::{Read, Write};
+
 use super::brotli::concat::{BroCatli, BroCatliResult};
 use super::brotli::enc::BrotliEncoderParams;
 use super::integration_tests::UnlimitedBuffer;
-use std::io::{Read, Write};
+use super::Rebox;
+
 static RANDOM_THEN_UNICODE: &[u8] = include_bytes!("../../testdata/random_then_unicode");
 static ALICE: &[u8] = include_bytes!("../../testdata/alice29.txt");
-use super::Rebox;
 
 #[test]
 fn test_custom_dict() {
diff --git a/src/bin/test_threading.rs b/src/bin/test_threading.rs
index 941406fe..ea1add34 100644
--- a/src/bin/test_threading.rs
+++ b/src/bin/test_threading.rs
@@ -1,20 +1,22 @@
 #![cfg(test)]
 #![allow(non_upper_case_globals)]
 #![allow(dead_code)]
+
 extern crate brotli_decompressor;
 extern crate core;
+
+use brotli::enc::threading::{Owned, SendAlloc};
+use brotli_decompressor::{SliceWrapper, SliceWrapperMut};
+
 use super::brotli::enc::{
     compress_multi, compress_multi_no_threadpool, BrotliEncoderMaxCompressedSizeMulti,
     BrotliEncoderParams, UnionHasher,
 };
-use super::new_brotli_heap_alloc;
-use brotli::enc::threading::{Owned, SendAlloc};
-use brotli_decompressor::{SliceWrapper, SliceWrapperMut};
-
 use super::integration_tests::UnlimitedBuffer;
+use super::{new_brotli_heap_alloc, Rebox};
+
 static RANDOM_THEN_UNICODE: &[u8] = include_bytes!("../../testdata/random_then_unicode");
 static ALICE: &[u8] = include_bytes!("../../testdata/alice29.txt");
-use super::Rebox;
 
 struct SliceRef<'a>(&'a [u8]);
 impl<'a> SliceWrapper<u8> for SliceRef<'a> {
diff --git a/src/bin/tests.rs b/src/bin/tests.rs
index 0d192c50..512693b8 100644
--- a/src/bin/tests.rs
+++ b/src/bin/tests.rs
@@ -1,5 +1,7 @@
 #![cfg(test)]
+
 extern crate core;
+
 use core::cmp::min;
 use std::io;
 
@@ -7,6 +9,7 @@ struct Buffer {
     data: Vec<u8>,
     read_offset: usize,
 }
+
 impl Buffer {
     pub fn new(buf: &[u8]) -> Buffer {
         let mut ret = Buffer {
diff --git a/src/enc/backward_references/test.rs b/src/enc/backward_references/test.rs
index a8616403..e0c2290e 100644
--- a/src/enc/backward_references/test.rs
+++ b/src/enc/backward_references/test.rs
@@ -1,11 +1,15 @@
 #![cfg(feature = "std")]
 #![cfg(test)]
+
+use alloc_stdlib::StandardAlloc;
+use enc::{Allocator, SliceWrapper};
+
 use super::{
     AdvHasher, AnyHasher, BrotliHasherParams, CloneWithAlloc, H5Sub, H9Opts, HQ7Sub, Struct1,
 };
-use alloc_stdlib::StandardAlloc;
-use enc::{Allocator, SliceWrapper};
+
 static RANDOM_THEN_UNICODE: &[u8] = include_bytes!("../../../testdata/random_then_unicode"); //&[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55];
+
 #[cfg(feature = "std")]
 #[test]
 fn test_bulk_store_range() {
diff --git a/src/enc/test.rs b/src/enc/test.rs
index 744472b6..e09fd447 100644
--- a/src/enc/test.rs
+++ b/src/enc/test.rs
@@ -1,33 +1,38 @@
 #![cfg(test)]
-use super::{s16, v8};
-use core;
-use core::cmp::min;
+
 extern crate alloc_no_stdlib;
 extern crate brotli_decompressor;
-use super::super::alloc::{
-    bzero, AllocatedStackMemory, Allocator, SliceWrapper, SliceWrapperMut, StackAllocator,
-};
-use super::cluster::HistogramPair;
-use super::encode::{BrotliEncoderOperation, BrotliEncoderParameter};
-use super::histogram::{ContextType, HistogramCommand, HistogramDistance, HistogramLiteral};
-use super::StaticCommand;
-use super::ZopfliNode;
-
 extern "C" {
     fn calloc(n_elem: usize, el_size: usize) -> *mut u8;
 }
 extern "C" {
     fn free(ptr: *mut u8);
 }
+
+// FIXME: Remove this after https://github.com/dropbox/rust-alloc-no-stdlib/issues/19 is fixed
+use alloc::{
+    declare_stack_allocator_struct, define_allocator_memory_pool, define_stack_allocator_traits,
+    static_array,
+};
+use core;
+use core::cmp::min;
+use core::ops;
+
+use brotli_decompressor::HuffmanCode;
+use enc::encode::BrotliEncoderStateStruct;
+
+use super::super::alloc::{
+    bzero, AllocatedStackMemory, Allocator, SliceWrapper, SliceWrapperMut, StackAllocator,
+};
 pub use super::super::{BrotliDecompressStream, BrotliResult, BrotliState};
+use super::cluster::HistogramPair;
 use super::combined_alloc::CombiningAllocator;
 use super::command::Command;
+use super::encode::{BrotliEncoderOperation, BrotliEncoderParameter};
 use super::entropy_encode::HuffmanTree;
-use super::interface;
+use super::histogram::{ContextType, HistogramCommand, HistogramDistance, HistogramLiteral};
 use super::pdf::PDF;
-use brotli_decompressor::HuffmanCode;
-use core::ops;
-use enc::encode::BrotliEncoderStateStruct;
+use super::{interface, s16, v8, StaticCommand, ZopfliNode};
 
 declare_stack_allocator_struct!(MemPool, 128, stack);
 declare_stack_allocator_struct!(CallocatedFreelist4096, 128, calloc);
@@ -307,8 +312,9 @@ fn test_roundtrip_10x10y() {
 
 macro_rules! test_roundtrip_file {
     ($filedata : expr, $bufsize: expr, $quality: expr, $lgwin: expr, $magic: expr, $in_buf:expr, $out_buf:expr) => {{
-        let stack_u8_buffer =
-            unsafe { define_allocator_memory_pool!(4096, u8, [0; 18 * 1024 * 1024], calloc) };
+        let stack_u8_buffer = unsafe {
+            alloc::define_allocator_memory_pool!(4096, u8, [0; 18 * 1024 * 1024], calloc)
+        };
         let mut stack_u8_allocator =
             CallocatedFreelist4096::<u8>::new_allocator(stack_u8_buffer.data, bzero);
 
diff --git a/src/ffi/multicompress/test.rs b/src/ffi/multicompress/test.rs
index c274ed29..3264b7bc 100644
--- a/src/ffi/multicompress/test.rs
+++ b/src/ffi/multicompress/test.rs
@@ -1,8 +1,12 @@
 #![cfg(test)]
 #![cfg(feature = "std")]
-use super::*;
+
 use core;
+
 use enc::encode::BrotliEncoderParameter;
+
+use super::*;
+
 #[test]
 fn test_compress_workpool() {
     let input = [