Skip to content

Commit 27ce5f5

Browse files
authored
Merge pull request #182 from nyurik/fmt2
Reorganize `use` statements, rm `unused_imports`
2 parents 333778a + 7b9cee5 commit 27ce5f5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+223
-162
lines changed

c/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
#![no_std]
22
#![cfg_attr(not(feature = "std"), feature(lang_items))]
3+
4+
pub extern crate brotli;
35
#[cfg(feature = "std")]
46
extern crate std;
57

6-
pub extern crate brotli;
7-
pub use brotli::ffi::compressor::*;
8+
use core::ptr::null_mut;
89

10+
pub use brotli::ffi::compressor::*;
911
// FIXME: this is just wrong, and needs to be fixed
1012
#[allow(unknown_lints, ambiguous_glob_reexports)]
1113
pub use brotli::ffi::decompressor::*;
12-
1314
pub use brotli::ffi::multicompress::*;
1415
pub use brotli::*;
15-
use core::ptr::null_mut;
16+
1617
#[cfg(feature = "std")]
1718
unsafe fn std_only_functions() {
1819
let _ =

justfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ fmt *ARGS:
3232
# Run Nightly cargo fmt, ordering imports by groups
3333
fmt2:
3434
cargo +nightly fmt -- --config imports_granularity=Module,group_imports=StdExternalCrate
35+
cd c && cargo +nightly fmt -- --config imports_granularity=Module,group_imports=StdExternalCrate
3536

3637
# Run cargo clippy
3738
clippy:

src/bin/brotli.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
#![cfg_attr(feature = "benchmark", feature(test))]
22

3+
extern crate alloc_no_stdlib;
4+
extern crate brotli;
5+
extern crate brotli_decompressor;
6+
extern crate core;
7+
#[cfg(feature = "validation")]
8+
extern crate sha2;
9+
310
pub mod integration_tests;
411
mod test_broccoli;
512
mod test_custom_dict;
613
mod test_threading;
714
mod tests;
815
mod util;
16+
mod validate;
917

10-
extern crate brotli;
11-
extern crate brotli_decompressor;
12-
extern crate core;
13-
#[cfg(feature = "validation")]
14-
extern crate sha2;
15-
#[allow(unused_imports)]
16-
#[macro_use]
17-
extern crate alloc_no_stdlib;
1818
use core::cmp::{max, min};
1919
use core::ops;
20+
use std::env;
21+
use std::fs::File;
22+
use std::io::{self, Error, ErrorKind, Read, Seek, SeekFrom, Write};
2023

21-
#[allow(unused_imports)]
22-
use alloc_no_stdlib::{
23-
bzero, AllocatedStackMemory, Allocator, SliceWrapper, SliceWrapperMut, StackAllocator,
24-
};
24+
use alloc_no_stdlib::{Allocator, SliceWrapper, SliceWrapperMut};
2525
use brotli::enc::backward_references::BrotliEncoderMode;
2626
use brotli::enc::threading::{
2727
BrotliEncoderThreadError, CompressMulti, CompressionThreadResult, Owned, SendAlloc,
@@ -31,12 +31,6 @@ use brotli::enc::{
3131
UnionHasher, WorkerPool,
3232
};
3333
use brotli::CustomRead;
34-
#[allow(unused_imports)]
35-
use brotli::HuffmanCode;
36-
mod validate;
37-
use std::env;
38-
use std::fs::File;
39-
use std::io::{self, Error, ErrorKind, Read, Seek, SeekFrom, Write};
4034

4135
const MAX_THREADS: usize = 16;
4236

src/bin/integration_tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#![cfg(test)]
22
#![allow(non_upper_case_globals)]
33
#![allow(dead_code)]
4+
45
extern crate brotli_decompressor;
56
extern crate core;
7+
68
use core::cmp::min;
79
use std::io;
810
#[cfg(feature = "std")]
@@ -13,7 +15,6 @@ use std::time::SystemTime;
1315

1416
use brotli::BrotliDecompressStream;
1517

16-
#[allow(unused_imports)]
1718
use super::alloc_no_stdlib::{Allocator, SliceWrapper, SliceWrapperMut};
1819
use super::brotli::{BrotliResult, BrotliState};
1920
#[cfg(feature = "std")]

src/bin/test_broccoli.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
#![cfg(test)]
22
#![allow(non_upper_case_globals)]
33
#![allow(dead_code)]
4+
45
extern crate brotli_decompressor;
56
extern crate core;
7+
68
use core::cmp::{max, min};
79

810
use brotli_decompressor::{CustomRead, CustomWrite};
911

1012
use super::brotli::concat::{BroCatli, BroCatliResult};
1113
use super::brotli::enc::BrotliEncoderParams;
1214
use super::integration_tests::UnlimitedBuffer;
15+
use super::Rebox;
16+
1317
static RANDOM_THEN_UNICODE: &[u8] = include_bytes!("../../testdata/random_then_unicode");
1418
static ALICE: &[u8] = include_bytes!("../../testdata/alice29.txt");
1519
static UKKONOOA: &[u8] = include_bytes!("../../testdata/ukkonooa");
@@ -20,7 +24,7 @@ static RANDOM10K: &[u8] = include_bytes!("../../testdata/random_org_10k.bin");
2024
static RANDOMTHENUNICODE: &[u8] = include_bytes!("../../testdata/random_then_unicode");
2125
static QUICKFOX: &[u8] = include_bytes!("../../testdata/quickfox_repeated");
2226
static EMPTY: &[u8] = &[];
23-
use super::Rebox;
27+
2428
fn concat(
2529
files: &mut [UnlimitedBuffer],
2630
brotli_files: &mut [UnlimitedBuffer],

src/bin/test_custom_dict.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
#![cfg(test)]
22
#![allow(non_upper_case_globals)]
33
#![allow(dead_code)]
4+
45
extern crate brotli_decompressor;
56
extern crate core;
7+
68
use std::io::{Read, Write};
79

810
use super::brotli::concat::{BroCatli, BroCatliResult};
911
use super::brotli::enc::BrotliEncoderParams;
1012
use super::integration_tests::UnlimitedBuffer;
13+
use super::Rebox;
14+
1115
static RANDOM_THEN_UNICODE: &[u8] = include_bytes!("../../testdata/random_then_unicode");
1216
static ALICE: &[u8] = include_bytes!("../../testdata/alice29.txt");
13-
use super::Rebox;
1417

1518
#[test]
1619
fn test_custom_dict() {

src/bin/test_threading.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#![cfg(test)]
22
#![allow(non_upper_case_globals)]
33
#![allow(dead_code)]
4+
45
extern crate brotli_decompressor;
56
extern crate core;
7+
68
use brotli::enc::threading::{Owned, SendAlloc};
79
use brotli_decompressor::{SliceWrapper, SliceWrapperMut};
810

@@ -11,10 +13,10 @@ use super::brotli::enc::{
1113
BrotliEncoderParams, UnionHasher,
1214
};
1315
use super::integration_tests::UnlimitedBuffer;
14-
use super::new_brotli_heap_alloc;
16+
use super::{new_brotli_heap_alloc, Rebox};
17+
1518
static RANDOM_THEN_UNICODE: &[u8] = include_bytes!("../../testdata/random_then_unicode");
1619
static ALICE: &[u8] = include_bytes!("../../testdata/alice29.txt");
17-
use super::Rebox;
1820

1921
struct SliceRef<'a>(&'a [u8]);
2022
impl<'a> SliceWrapper<u8> for SliceRef<'a> {

src/bin/tests.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
#![cfg(test)]
2+
23
extern crate core;
4+
35
use core::cmp::min;
46
use std::io;
57

68
struct Buffer {
79
data: Vec<u8>,
810
read_offset: usize,
911
}
12+
1013
impl Buffer {
1114
pub fn new(buf: &[u8]) -> Buffer {
1215
let mut ret = Buffer {

src/bin/util.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use core::marker::PhantomData;
22
use core::mem;
3+
use std;
34
use std::collections::BTreeMap;
45
use std::fmt;
56
use std::thread::JoinHandle;

src/enc/backward_references/benchmark.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#![cfg(feature = "benchmark")]
22
#![cfg(feature = "std")]
3+
34
extern crate test;
5+
46
use alloc_stdlib::StandardAlloc;
57

68
use super::*;
9+
710
static RANDOM_THEN_UNICODE: &'static [u8] = include_bytes!("../../../testdata/random_then_unicode");
811
static FINALIZE_DATA: &'static [u8] = &[
912
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,
@@ -13,6 +16,7 @@ static FINALIZE_DATA: &'static [u8] = &[
1316
];
1417
const TEST_LEN: usize = 256 * 1024;
1518
const DISTANCE_CACHE: &'static [i32] = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; // distance cache
19+
1620
fn make_generic_hasher() -> AdvHasher<H5Sub, StandardAlloc> {
1721
let params_hasher = BrotliHasherParams {
1822
type_: 5,

0 commit comments

Comments
 (0)