Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy complaints #6573

Merged
merged 3 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions arrow-arith/src/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,14 @@ fn aggregate_nullable_chunk<T: ArrowNativeTypeOp, A: NumericAccumulator<T>, cons
}

fn aggregate_nonnull_simple<T: ArrowNativeTypeOp, A: NumericAccumulator<T>>(values: &[T]) -> T {
return values
values
.iter()
.copied()
.fold(A::default(), |mut a, b| {
a.accumulate(b);
a
})
.finish();
.finish()
}

#[inline(never)]
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/array/boolean_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ impl Array for BooleanArray {
}
}

impl<'a> ArrayAccessor for &'a BooleanArray {
impl ArrayAccessor for &BooleanArray {
type Item = bool;

fn value(&self, index: usize) -> Self::Item {
Expand Down
10 changes: 5 additions & 5 deletions arrow-array/src/array/dictionary_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -799,15 +799,15 @@ pub struct TypedDictionaryArray<'a, K: ArrowDictionaryKeyType, V> {
}

// Manually implement `Clone` to avoid `V: Clone` type constraint
impl<'a, K: ArrowDictionaryKeyType, V> Clone for TypedDictionaryArray<'a, K, V> {
impl<K: ArrowDictionaryKeyType, V> Clone for TypedDictionaryArray<'_, K, V> {
fn clone(&self) -> Self {
*self
}
}

impl<'a, K: ArrowDictionaryKeyType, V> Copy for TypedDictionaryArray<'a, K, V> {}
impl<K: ArrowDictionaryKeyType, V> Copy for TypedDictionaryArray<'_, K, V> {}

impl<'a, K: ArrowDictionaryKeyType, V> std::fmt::Debug for TypedDictionaryArray<'a, K, V> {
impl<K: ArrowDictionaryKeyType, V> std::fmt::Debug for TypedDictionaryArray<'_, K, V> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
writeln!(f, "TypedDictionaryArray({:?})", self.dictionary)
}
Expand All @@ -825,7 +825,7 @@ impl<'a, K: ArrowDictionaryKeyType, V> TypedDictionaryArray<'a, K, V> {
}
}

impl<'a, K: ArrowDictionaryKeyType, V: Sync> Array for TypedDictionaryArray<'a, K, V> {
impl<K: ArrowDictionaryKeyType, V: Sync> Array for TypedDictionaryArray<'_, K, V> {
fn as_any(&self) -> &dyn Any {
self.dictionary
}
Expand Down Expand Up @@ -879,7 +879,7 @@ impl<'a, K: ArrowDictionaryKeyType, V: Sync> Array for TypedDictionaryArray<'a,
}
}

impl<'a, K, V> IntoIterator for TypedDictionaryArray<'a, K, V>
impl<K, V> IntoIterator for TypedDictionaryArray<'_, K, V>
where
K: ArrowDictionaryKeyType,
Self: ArrayAccessor,
Expand Down
20 changes: 10 additions & 10 deletions arrow-array/src/array/fixed_size_list_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@ use std::sync::Arc;
///
/// ```text
/// ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐
/// ┌ ─ ─ ─ ─ ─ ─ ─ ─┐
/// ┌ ─ ─ ─ ─ ─ ─ ─ ─┐
/// ┌─────────────┐ │ ┌───┐ ┌───┐ ┌──────┐ │
/// │ [A,B] │ │ 1 │ │ │ 1 │ │ A │ │ 0
/// │ [A,B] │ │ 1 │ │ │ 1 │ │ A │ │ 0
/// ├─────────────┤ │ ├───┤ ├───┤ ├──────┤ │
/// │ NULL │ │ 0 │ │ │ 1 │ │ B │ │ 1
/// │ NULL │ │ 0 │ │ │ 1 │ │ B │ │ 1
/// ├─────────────┤ │ ├───┤ ├───┤ ├──────┤ │
/// │ [C,NULL] │ │ 1 │ │ │ 0 │ │ ???? │ │ 2
/// │ [C,NULL] │ │ 1 │ │ │ 0 │ │ ???? │ │ 2
/// └─────────────┘ │ └───┘ ├───┤ ├──────┤ │
/// | │ 0 │ │ ???? │ │ 3
/// | │ 0 │ │ ???? │ │ 3
/// Logical Values │ Validity ├───┤ ├──────┤ │
/// (nulls) │ │ 1 │ │ C │ │ 4
/// (nulls) │ │ 1 │ │ C │ │ 4
/// │ ├───┤ ├──────┤ │
/// │ │ 0 │ │ ???? │ │ 5
/// │ │ 0 │ │ ???? │ │ 5
/// │ └───┘ └──────┘ │
/// │ Values │
/// │ Values │
/// │ FixedSizeListArray (Array) │
/// └ ─ ─ ─ ─ ─ ─ ─ ─┘
/// └ ─ ─ ─ ─ ─ ─ ─ ─┘
/// └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘
/// ```
///
Expand Down Expand Up @@ -448,7 +448,7 @@ impl std::fmt::Debug for FixedSizeListArray {
}
}

impl<'a> ArrayAccessor for &'a FixedSizeListArray {
impl ArrayAccessor for &FixedSizeListArray {
type Item = ArrayRef;

fn value(&self, index: usize) -> Self::Item {
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/array/list_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ impl<OffsetSize: OffsetSizeTrait> Array for GenericListArray<OffsetSize> {
}
}

impl<'a, OffsetSize: OffsetSizeTrait> ArrayAccessor for &'a GenericListArray<OffsetSize> {
impl<OffsetSize: OffsetSizeTrait> ArrayAccessor for &GenericListArray<OffsetSize> {
type Item = ArrayRef;

fn value(&self, index: usize) -> Self::Item {
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/array/list_view_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl<OffsetSize: OffsetSizeTrait> GenericListViewArray<OffsetSize> {
}
}

impl<'a, OffsetSize: OffsetSizeTrait> ArrayAccessor for &'a GenericListViewArray<OffsetSize> {
impl<OffsetSize: OffsetSizeTrait> ArrayAccessor for &GenericListViewArray<OffsetSize> {
type Item = ArrayRef;

fn value(&self, index: usize) -> Self::Item {
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/array/map_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ impl Array for MapArray {
}
}

impl<'a> ArrayAccessor for &'a MapArray {
impl ArrayAccessor for &MapArray {
type Item = StructArray;

fn value(&self, index: usize) -> Self::Item {
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ impl Array for ArrayRef {
}
}

impl<'a, T: Array> Array for &'a T {
impl<T: Array> Array for &T {
fn as_any(&self) -> &dyn Any {
T::as_any(self)
}
Expand Down
3 changes: 1 addition & 2 deletions arrow-array/src/array/primitive_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,6 @@ impl<T: ArrowPrimitiveType> PrimitiveArray<T> {
/// let c = a.unary_mut(|x| x * 2 + 1).unwrap();
/// assert_eq!(c, Int32Array::from(vec![Some(11), Some(15), None]));
/// ```

pub fn unary_mut<F>(self, op: F) -> Result<PrimitiveArray<T>, PrimitiveArray<T>>
where
F: Fn(T::Native) -> T::Native,
Expand Down Expand Up @@ -1174,7 +1173,7 @@ impl<T: ArrowPrimitiveType> Array for PrimitiveArray<T> {
}
}

impl<'a, T: ArrowPrimitiveType> ArrayAccessor for &'a PrimitiveArray<T> {
impl<T: ArrowPrimitiveType> ArrayAccessor for &PrimitiveArray<T> {
type Item = T::Native;

fn value(&self, index: usize) -> Self::Item {
Expand Down
17 changes: 8 additions & 9 deletions arrow-array/src/array/run_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,22 @@ use crate::{
/// ```text
/// ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─┐
/// ┌─────────────────┐ ┌─────────┐ ┌─────────────────┐
/// │ │ A │ │ 2 │ │ │ A │
/// │ │ A │ │ 2 │ │ │ A │
/// ├─────────────────┤ ├─────────┤ ├─────────────────┤
/// │ │ D │ │ 3 │ │ │ A │ run length of 'A' = runs_ends[0] - 0 = 2
/// ├─────────────────┤ ├─────────┤ ├─────────────────┤
/// │ │ B │ │ 6 │ │ │ D │ run length of 'D' = run_ends[1] - run_ends[0] = 1
/// └─────────────────┘ └─────────┘ ├─────────────────┤
/// │ values run_ends │ │ B │
/// │ values run_ends │ │ B │
/// ├─────────────────┤
/// └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─┘ │ B │
/// └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─┘ │ B │
/// ├─────────────────┤
/// RunArray │ B │ run length of 'B' = run_ends[2] - run_ends[1] = 3
/// length = 3 └─────────────────┘
///
///
/// Logical array
/// Contents
/// ```

pub struct RunArray<R: RunEndIndexType> {
data_type: DataType,
run_ends: RunEndBuffer<R::Native>,
Expand Down Expand Up @@ -525,15 +524,15 @@ pub struct TypedRunArray<'a, R: RunEndIndexType, V> {
}

// Manually implement `Clone` to avoid `V: Clone` type constraint
impl<'a, R: RunEndIndexType, V> Clone for TypedRunArray<'a, R, V> {
impl<R: RunEndIndexType, V> Clone for TypedRunArray<'_, R, V> {
fn clone(&self) -> Self {
*self
}
}

impl<'a, R: RunEndIndexType, V> Copy for TypedRunArray<'a, R, V> {}
impl<R: RunEndIndexType, V> Copy for TypedRunArray<'_, R, V> {}

impl<'a, R: RunEndIndexType, V> std::fmt::Debug for TypedRunArray<'a, R, V> {
impl<R: RunEndIndexType, V> std::fmt::Debug for TypedRunArray<'_, R, V> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
writeln!(f, "TypedRunArray({:?})", self.run_array)
}
Expand All @@ -556,7 +555,7 @@ impl<'a, R: RunEndIndexType, V> TypedRunArray<'a, R, V> {
}
}

impl<'a, R: RunEndIndexType, V: Sync> Array for TypedRunArray<'a, R, V> {
impl<R: RunEndIndexType, V: Sync> Array for TypedRunArray<'_, R, V> {
fn as_any(&self) -> &dyn Any {
self.run_array
}
Expand Down
1 change: 0 additions & 1 deletion arrow-array/src/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ macro_rules! downcast_primitive_array {
/// .downcast_ref::<Int32Array>()
/// .unwrap();
/// ```

pub fn as_primitive_array<T>(arr: &dyn Array) -> &PrimitiveArray<T>
where
T: ArrowPrimitiveType,
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ struct ImportedArrowArray<'a> {
owner: &'a Arc<FFI_ArrowArray>,
}

impl<'a> ImportedArrowArray<'a> {
impl ImportedArrowArray<'_> {
fn consume(self) -> Result<ArrayData> {
let len = self.array.len();
let offset = self.array.offset();
Expand Down
2 changes: 1 addition & 1 deletion arrow-avro/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub struct Attributes<'a> {
pub additional: HashMap<&'a str, serde_json::Value>,
}

impl<'a> Attributes<'a> {
impl Attributes<'_> {
/// Returns the field metadata for this [`Attributes`]
pub(crate) fn field_metadata(&self) -> HashMap<String, String> {
self.additional
Expand Down
10 changes: 5 additions & 5 deletions arrow-buffer/src/util/bit_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl<'a> BitIterator<'a> {
}
}

impl<'a> Iterator for BitIterator<'a> {
impl Iterator for BitIterator<'_> {
type Item = bool;

fn next(&mut self) -> Option<Self::Item> {
Expand All @@ -73,9 +73,9 @@ impl<'a> Iterator for BitIterator<'a> {
}
}

impl<'a> ExactSizeIterator for BitIterator<'a> {}
impl ExactSizeIterator for BitIterator<'_> {}

impl<'a> DoubleEndedIterator for BitIterator<'a> {
impl DoubleEndedIterator for BitIterator<'_> {
fn next_back(&mut self) -> Option<Self::Item> {
if self.current_offset == self.end_offset {
return None;
Expand Down Expand Up @@ -138,7 +138,7 @@ impl<'a> BitSliceIterator<'a> {
}
}

impl<'a> Iterator for BitSliceIterator<'a> {
impl Iterator for BitSliceIterator<'_> {
type Item = (usize, usize);

fn next(&mut self) -> Option<Self::Item> {
Expand Down Expand Up @@ -211,7 +211,7 @@ impl<'a> BitIndexIterator<'a> {
}
}

impl<'a> Iterator for BitIndexIterator<'a> {
impl Iterator for BitIndexIterator<'_> {
type Item = usize;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
2 changes: 1 addition & 1 deletion arrow-buffer/src/util/bit_mask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ mod tests {

/// prints a byte slice as a binary string like "01010101 10101010"
struct BinaryFormatter<'a>(&'a [u8]);
impl<'a> Display for BinaryFormatter<'a> {
impl Display for BinaryFormatter<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
for byte in self.0 {
write!(f, "{:08b} ", byte)?;
Expand Down
2 changes: 1 addition & 1 deletion arrow-buffer/src/util/bit_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn round_upto_multiple_of_64(num: usize) -> usize {
/// Returns the nearest multiple of `factor` that is `>=` than `num`. Here `factor` must
/// be a power of 2.
pub fn round_upto_power_of_2(num: usize, factor: usize) -> usize {
debug_assert!(factor > 0 && (factor & (factor - 1)) == 0);
debug_assert!(factor > 0 && factor.is_power_of_two());
Copy link
Contributor

@Dandandan Dandandan Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice

num.checked_add(factor - 1)
.expect("failed to round to next highest power of 2")
& !(factor - 1)
Expand Down
2 changes: 1 addition & 1 deletion arrow-cast/src/cast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub struct CastOptions<'a> {
pub format_options: FormatOptions<'a>,
}

impl<'a> Default for CastOptions<'a> {
impl Default for CastOptions<'_> {
fn default() -> Self {
Self {
safe: true,
Expand Down
Loading
Loading