Skip to content

Commit

Permalink
Remove redundant imports
Browse files Browse the repository at this point in the history
Rust 1.78 Nightly started to raise warning about duplicate imports.
For instance, if `std::vec::Vec` is already imported, an attempt to import
`alloc::vec::Vec` (the same type as `std::vec::Vec`) will cause a warning.

This commit gates such imports behind `not(any(test, feature = "std"))`.
  • Loading branch information
a4lg committed Feb 25, 2024
1 parent e6faaba commit 6964f7b
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 4 deletions.
3 changes: 3 additions & 0 deletions crates/base32-simd/src/heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ use crate::{AppendBase32Decode, AppendBase32Encode, Base32, Error, FromBase32Dec

use vsimd::tools::{alloc_uninit_bytes, assume_init, boxed_str, slice_parts};

#[cfg(not(any(test, feature = "std")))]
use alloc::boxed::Box;
#[cfg(not(any(test, feature = "std")))]
use alloc::string::String;
#[cfg(not(any(test, feature = "std")))]
use alloc::vec::Vec;

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion crates/base32-simd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ use crate::encode::encoded_length_unchecked;

use vsimd::tools::{slice_mut, slice_parts};

#[cfg(feature = "alloc")]
#[cfg(all(feature = "alloc", not(any(test, feature = "std"))))]
use alloc::{string::String, vec::Vec};

const BASE32_CHARSET: &[u8; 32] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
Expand Down
2 changes: 1 addition & 1 deletion crates/base64-simd/src/forgiving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use vsimd::tools::slice_mut;

use core::ptr::copy_nonoverlapping;

#[cfg(feature = "alloc")]
#[cfg(all(feature = "alloc", not(any(test, feature = "std"))))]
use alloc::vec::Vec;

/// Forgiving decodes a base64 string to bytes and writes inplace.
Expand Down
3 changes: 3 additions & 0 deletions crates/base64-simd/src/heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ use crate::{FromBase64Decode, FromBase64Encode};

use vsimd::tools::{alloc_uninit_bytes, assume_init, boxed_str, slice_parts};

#[cfg(not(any(test, feature = "std")))]
use alloc::boxed::Box;
#[cfg(not(any(test, feature = "std")))]
use alloc::string::String;
#[cfg(not(any(test, feature = "std")))]
use alloc::vec::Vec;

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion crates/base64-simd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ use crate::encode::encoded_length_unchecked;

use vsimd::tools::{slice_mut, slice_parts};

#[cfg(feature = "alloc")]
#[cfg(all(feature = "alloc", not(any(test, feature = "std"))))]
use alloc::{string::String, vec::Vec};

const STANDARD_CHARSET: &[u8; 64] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
Expand Down
3 changes: 3 additions & 0 deletions crates/hex-simd/src/heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ use crate::{AppendHexDecode, AppendHexEncode, AsciiCase, Error, FromHexDecode, F

use vsimd::tools::{alloc_uninit_bytes, assume_init, boxed_str, slice_parts};

#[cfg(not(any(test, feature = "std")))]
use alloc::boxed::Box;
#[cfg(not(any(test, feature = "std")))]
use alloc::string::String;
#[cfg(not(any(test, feature = "std")))]
use alloc::vec::Vec;

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion crates/hex-simd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub use vsimd::ascii::AsciiCase;

use vsimd::tools::{slice_mut, slice_parts};

#[cfg(feature = "alloc")]
#[cfg(all(feature = "alloc", not(any(test, feature = "std"))))]
use alloc::{string::String, vec::Vec};

/// Calculates the encoded length.
Expand Down

0 comments on commit 6964f7b

Please sign in to comment.