Skip to content

Commit

Permalink
remove by no unneded import workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
rustonaut committed Mar 22, 2024
1 parent 3500caa commit 4958eb7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
19 changes: 17 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,19 @@ mod shared;
pub mod smallvec_v1;

use core::{
fmt,
iter::{DoubleEndedIterator, ExactSizeIterator, Extend, IntoIterator, Peekable},
ops::RangeBounds,
result::Result as StdResult,
};

use alloc::{collections::BinaryHeap, collections::VecDeque, rc::Rc, string::String, vec};
use alloc::{
boxed::Box,
collections::{BinaryHeap, VecDeque},
rc::Rc,
string::String,
vec::{self, Vec},
};

#[cfg(feature = "std")]
use std::{
Expand All @@ -137,7 +145,6 @@ use std::{
use std::error::Error;

use alloc::vec::Drain;
shared_impl! {@IMPORTS}

/// Error returned by operations which would cause `Vec1` to have a length of 0.
#[derive(Debug, Hash, Eq, PartialEq, Copy, Clone)]
Expand Down Expand Up @@ -1373,6 +1380,8 @@ mod test {
}

mod Borrow {
use core::borrow::Borrow as _;

use crate::*;

#[test]
Expand All @@ -1391,6 +1400,8 @@ mod test {
}

mod BorrowMut {
use core::borrow::BorrowMut as _;

use crate::*;

#[test]
Expand Down Expand Up @@ -1429,6 +1440,8 @@ mod test {
}

mod Deref {
use core::ops::Deref;

use crate::*;

#[test]
Expand All @@ -1440,6 +1453,8 @@ mod test {
}

mod DerefMut {
use core::ops::DerefMut;

use crate::*;

#[test]
Expand Down
31 changes: 13 additions & 18 deletions src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,6 @@ macro_rules! impl_wrapper {
}

macro_rules! shared_impl {
//Workaround for limitations of rustdoc
(@IMPORTS) => (
use core::{
borrow::{Borrow, BorrowMut},
cmp::{Eq, Ord, Ordering, PartialEq},
convert::TryFrom,
fmt::{self, Debug},
hash::{Hash, Hasher},
ops::{Deref, DerefMut, Index, IndexMut, RangeBounds},
slice::SliceIndex,
};
use alloc::{vec::Vec, boxed::Box};
);
(
base_bounds_macro = $($tb:ident : $trait:ident)?,
item_ty_macro = $item_ty:ty,
Expand All @@ -89,10 +76,18 @@ macro_rules! shared_impl {
where
$($tb : $trait,)?;

// FIXME: This is currently not possible as this will cause the
// methods not to be documented by rustdoc:
// https://github.com/rust-lang/rust/issues/83026
// const _: () = {
const _: () = {
use core::{
borrow::{Borrow, BorrowMut},
cmp::{Eq, Ord, Ordering, PartialEq},
convert::TryFrom,
fmt::{self, Debug},
hash::{Hash, Hasher},
ops::{Deref, DerefMut, Index, IndexMut, RangeBounds},
slice::SliceIndex,
};
use alloc::{vec::Vec, boxed::Box};

impl<$t> $name<$t>
where
$($tb : $trait,)?
Expand Down Expand Up @@ -962,7 +957,7 @@ macro_rules! shared_impl {
}
}
};
// };
};
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/smallvec_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ use crate::Size0Error;
#[cfg(feature = "smallvec-v1-write")]
use std::io;

use alloc::boxed::Box;
use alloc::vec::Vec;
use smallvec::*;
use smallvec_v1_ as smallvec;

pub use crate::__smallvec1_inline_macro_v1 as smallvec1_inline;
pub use crate::__smallvec1_macro_v1 as smallvec1;

use smallvec::Drain;
shared_impl! {@IMPORTS}

#[doc(hidden)]
#[macro_export]
Expand Down

0 comments on commit 4958eb7

Please sign in to comment.