Skip to content
This repository was archived by the owner on Nov 27, 2020. It is now read-only.

Commit bcc633e

Browse files
committed
Allow clippy warnings
1 parent a3fa917 commit bcc633e

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

src/boxed.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl<T, A: AllocRef> Box<T, A> {
182182
/// # #[allow(unused_variables)]
183183
/// let five = Box::new_in(5, Global);
184184
/// ```
185-
#[allow(clippy::inline_always)]
185+
#[allow(clippy::inline_always, clippy::needless_pass_by_value)]
186186
#[inline(always)]
187187
pub fn new_in(x: T, a: A) -> Self {
188188
unsafe { Self::try_new_in(x, a).unwrap_unchecked() }
@@ -201,6 +201,7 @@ impl<T, A: AllocRef> Box<T, A> {
201201
/// let five = Box::try_new_in(5, Global)?;
202202
/// # Ok::<_, alloc_wg::alloc::AllocErr>(())
203203
/// ```
204+
#[allow(clippy::needless_pass_by_value)]
204205
pub fn try_new_in(x: T, a: A) -> Result<Self, A::Error> {
205206
let ptr = if let Ok(layout) = NonZeroLayout::new::<T>() {
206207
let ptr = a.alloc(layout)?.cast::<T>();
@@ -232,7 +233,7 @@ impl<T, A: AllocRef> Box<T, A> {
232233
///
233234
/// assert_eq!(*five, 5)
234235
/// ```
235-
#[allow(clippy::inline_always)]
236+
#[allow(clippy::inline_always, clippy::needless_pass_by_value)]
236237
#[inline(always)]
237238
pub fn new_uninit_in(a: A) -> Box<mem::MaybeUninit<T>, A> {
238239
unsafe { Self::try_new_uninit_in(a).unwrap_unchecked() }
@@ -257,6 +258,7 @@ impl<T, A: AllocRef> Box<T, A> {
257258
/// assert_eq!(*five, 5);
258259
/// # Ok::<_, alloc_wg::alloc::AllocErr>(())
259260
/// ```
261+
#[allow(clippy::needless_pass_by_value)]
260262
pub fn try_new_uninit_in(a: A) -> Result<Box<mem::MaybeUninit<T>, A>, A::Error> {
261263
let ptr = if let Ok(layout) = NonZeroLayout::new::<T>() {
262264
let ptr: NonNull<mem::MaybeUninit<T>> = a.alloc(layout)?.cast();
@@ -269,14 +271,15 @@ impl<T, A: AllocRef> Box<T, A> {
269271

270272
/// Constructs a new `Pin<Box<T, A>>` with the specified allocator. If `T` does not implement
271273
/// `Unpin`, then `x` will be pinned in memory and unable to be moved.
272-
#[allow(clippy::inline_always)]
274+
#[allow(clippy::inline_always, clippy::needless_pass_by_value)]
273275
#[inline(always)]
274276
pub fn pin_in(x: T, a: A) -> Pin<Self> {
275277
unsafe { Self::try_pin_in(x, a).unwrap_unchecked() }
276278
}
277279

278280
/// Constructs a new `Pin<Box<T, A>>` with the specified allocator. If `T` does not implement
279281
/// `Unpin`, then `x` will be pinned in memory and unable to be moved.
282+
#[allow(clippy::needless_pass_by_value)]
280283
#[inline]
281284
pub fn try_pin_in(x: T, a: A) -> Result<Pin<Self>, A::Error> {
282285
Self::try_new_in(x, a).map(Pin::from)
@@ -335,7 +338,7 @@ impl<T, A: AllocRef> Box<[T], A> {
335338
///
336339
/// assert_eq!(*values, [1, 2, 3]);
337340
/// ```
338-
#[allow(clippy::inline_always)]
341+
#[allow(clippy::inline_always, clippy::needless_pass_by_value)]
339342
#[inline(always)]
340343
pub fn new_uninit_slice_in(len: usize, a: A) -> Box<[mem::MaybeUninit<T>], A> {
341344
unsafe { Self::try_new_uninit_slice_in(len, a).unwrap_unchecked() }
@@ -363,6 +366,7 @@ impl<T, A: AllocRef> Box<[T], A> {
363366
/// assert_eq!(*values, [1, 2, 3]);
364367
/// # Ok::<_, alloc_wg::collections::CollectionAllocErr<Global>>(())
365368
/// ```
369+
#[allow(clippy::needless_pass_by_value)]
366370
pub fn try_new_uninit_slice_in(
367371
len: usize,
368372
a: A,

src/raw_vec.rs

+6
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ impl<T> RawVec<T> {
144144

145145
impl<T, A: DeallocRef> RawVec<T, A> {
146146
/// Like `new` but parameterized over the choice of allocator for the returned `RawVec`.
147+
#[allow(clippy::needless_pass_by_value)]
147148
pub fn new_in(a: A) -> Self {
148149
let capacity = if mem::size_of::<T>() == 0 { !0 } else { 0 };
149150
Self {
@@ -161,6 +162,7 @@ impl<T, A: DeallocRef> RawVec<T, A> {
161162
///
162163
/// * if the requested capacity exceeds `usize::MAX` bytes.
163164
/// * on 32-bit platforms if the requested capacity exceeds `isize::MAX` bytes.
165+
#[allow(clippy::needless_pass_by_value)]
164166
pub fn with_capacity_in(capacity: usize, a: A) -> Self
165167
where
166168
A: AllocRef,
@@ -181,6 +183,7 @@ impl<T, A: DeallocRef> RawVec<T, A> {
181183
/// * `CapacityOverflow` if the requested capacity exceeds `usize::MAX` bytes.
182184
/// * `CapacityOverflow` on 32-bit platforms if the requested capacity exceeds `isize::MAX` bytes.
183185
/// * `AllocError` on OOM
186+
#[allow(clippy::needless_pass_by_value)]
184187
pub fn try_with_capacity_in(capacity: usize, a: A) -> Result<Self, CollectionAllocErr<A>>
185188
where
186189
A: AllocRef,
@@ -196,6 +199,7 @@ impl<T, A: DeallocRef> RawVec<T, A> {
196199
///
197200
/// * if the requested capacity exceeds `usize::MAX` bytes.
198201
/// * on 32-bit platforms if the requested capacity exceeds `isize::MAX` bytes.
202+
#[allow(clippy::needless_pass_by_value)]
199203
pub fn with_capacity_zeroed_in(capacity: usize, a: A) -> Self
200204
where
201205
A: AllocRef,
@@ -216,13 +220,15 @@ impl<T, A: DeallocRef> RawVec<T, A> {
216220
/// * `CapacityOverflow` if the requested capacity exceeds `usize::MAX` bytes.
217221
/// * `CapacityOverflow` on 32-bit platforms if the requested capacity exceeds `isize::MAX` bytes.
218222
/// * `AllocError` on OOM
223+
#[allow(clippy::needless_pass_by_value)]
219224
pub fn try_with_capacity_zeroed_in(capacity: usize, a: A) -> Result<Self, CollectionAllocErr<A>>
220225
where
221226
A: AllocRef,
222227
{
223228
Self::allocate_in(capacity, true, a)
224229
}
225230

231+
#[allow(clippy::needless_pass_by_value)]
226232
fn allocate_in(capacity: usize, zeroed: bool, alloc: A) -> Result<Self, CollectionAllocErr<A>>
227233
where
228234
A: AllocRef,

src/string.rs

+8
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ impl String {
566566

567567
impl<A: DeallocRef> String<A> {
568568
/// Like `new` but parameterized over the choice of allocator for the returned `String`.
569+
#[allow(clippy::needless_pass_by_value)]
569570
#[inline]
570571
pub fn new_in(a: A) -> Self {
571572
Self {
@@ -577,6 +578,7 @@ impl<A: DeallocRef> String<A> {
577578
///
578579
/// # Panics
579580
/// Panics if the allocation fails.
581+
#[allow(clippy::needless_pass_by_value)]
580582
#[inline]
581583
pub fn with_capacity_in(capacity: usize, a: A) -> Self
582584
where
@@ -588,6 +590,7 @@ impl<A: DeallocRef> String<A> {
588590
}
589591

590592
/// Like `with_capacity_in` but returns errors instead of panicking.
593+
#[allow(clippy::needless_pass_by_value)]
591594
#[inline]
592595
pub fn try_with_capacity_in(capacity: usize, a: A) -> Result<Self, CollectionAllocErr<A>>
593596
where
@@ -602,6 +605,7 @@ impl<A: DeallocRef> String<A> {
602605
///
603606
/// # Panics
604607
/// Panics if the allocation fails.
608+
#[allow(clippy::needless_pass_by_value)]
605609
#[inline]
606610
pub fn from_str_in(s: &str, a: A) -> Self
607611
where
@@ -613,6 +617,7 @@ impl<A: DeallocRef> String<A> {
613617
}
614618

615619
/// Like `from_str_in` but returns errors instead of panicking.
620+
#[allow(clippy::needless_pass_by_value)]
616621
#[inline]
617622
pub fn try_from_str_in(s: &str, a: A) -> Result<Self, CollectionAllocErr<A>>
618623
where
@@ -703,6 +708,7 @@ impl<A: DeallocRef> String<A> {
703708
/// # Panics
704709
///
705710
/// Panics if allocation fails.
711+
#[allow(clippy::needless_pass_by_value)]
706712
pub fn from_utf8_lossy_in(v: &[u8], a: A) -> Self
707713
where
708714
A: ReallocRef,
@@ -715,6 +721,7 @@ impl<A: DeallocRef> String<A> {
715721
}
716722

717723
/// Like `from_utf8_lossy_in` but returns errors instead of panicking.
724+
#[allow(clippy::needless_pass_by_value)]
718725
pub fn try_from_utf8_lossy_in(v: &[u8], a: A) -> Result<Self, CollectionAllocErr<A>>
719726
where
720727
A: ReallocRef,
@@ -751,6 +758,7 @@ impl<A: DeallocRef> String<A> {
751758
}
752759

753760
/// Like `from_utf16` but parameterized over the choice of allocator for the returned `String`.
761+
#[allow(clippy::needless_pass_by_value)]
754762
pub fn from_utf16_in(v: &[u16], a: A) -> Result<Self, FromUtf16Error>
755763
where
756764
A: ReallocRef,

src/vec.rs

+3
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ impl<T> Vec<T> {
472472

473473
impl<T, A: DeallocRef> Vec<T, A> {
474474
/// Like `new` but parameterized over the choice of allocator for the returned `Vec`.
475+
#[allow(clippy::needless_pass_by_value)]
475476
#[inline]
476477
pub fn new_in(a: A) -> Self {
477478
Self {
@@ -487,6 +488,7 @@ impl<T, A: DeallocRef> Vec<T, A> {
487488
///
488489
/// * if the requested capacity exceeds `usize::MAX` bytes.
489490
/// * on 32-bit platforms if the requested capacity exceeds `isize::MAX` bytes.
491+
#[allow(clippy::needless_pass_by_value)]
490492
#[inline]
491493
pub fn with_capacity_in(capacity: usize, a: A) -> Self
492494
where
@@ -506,6 +508,7 @@ impl<T, A: DeallocRef> Vec<T, A> {
506508
/// * `CapacityOverflow` if the requested capacity exceeds `usize::MAX` bytes.
507509
/// * `CapacityOverflow` on 32-bit platforms if the requested capacity exceeds `isize::MAX` bytes.
508510
/// * `AllocError` on OOM
511+
#[allow(clippy::needless_pass_by_value)]
509512
#[inline]
510513
pub fn try_with_capacity_in(capacity: usize, a: A) -> Result<Self, CollectionAllocErr<A>>
511514
where

0 commit comments

Comments
 (0)