Skip to content

Commit a0c3186

Browse files
authored
Fix some Clippy 1.85 warnings (#7167)
1 parent 66498b4 commit a0c3186

File tree

10 files changed

+21
-21
lines changed

10 files changed

+21
-21
lines changed

arrow-array/src/array/union_array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ fn selection_mask(type_ids_chunk: &[i8], type_id: i8) -> u64 {
994994
.copied()
995995
.enumerate()
996996
.fold(0, |packed, (bit_idx, v)| {
997-
packed | ((v == type_id) as u64) << bit_idx
997+
packed | (((v == type_id) as u64) << bit_idx)
998998
})
999999
}
10001000

arrow-buffer/src/bigint/div.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ fn full_shl<const N: usize>(v: &[u64; N], shift: u32) -> ArrayPlusOne<u64, N> {
258258
let mut out = [0u64; N];
259259
out[0] = v[0] << shift;
260260
for i in 1..N {
261-
out[i] = v[i - 1] >> (64 - shift) | v[i] << shift
261+
out[i] = (v[i - 1] >> (64 - shift)) | (v[i] << shift)
262262
}
263263
let carry = v[N - 1] >> (64 - shift);
264264
ArrayPlusOne(out, carry)
@@ -272,7 +272,7 @@ fn full_shr<const N: usize>(a: &ArrayPlusOne<u64, N>, shift: u32) -> [u64; N] {
272272
}
273273
let mut out = [0; N];
274274
for i in 0..N - 1 {
275-
out[i] = a[i] >> shift | a[i + 1] << (64 - shift)
275+
out[i] = (a[i] >> shift) | (a[i + 1] << (64 - shift))
276276
}
277277
out[N - 1] = a[N - 1] >> shift;
278278
out

arrow-buffer/src/bigint/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ impl i256 {
475475
/// Interpret 4 `u64` digits, least significant first, as a [`i256`]
476476
fn from_digits(digits: [u64; 4]) -> Self {
477477
Self::from_parts(
478-
digits[0] as u128 | (digits[1] as u128) << 64,
479-
digits[2] as i128 | (digits[3] as i128) << 64,
478+
digits[0] as u128 | ((digits[1] as u128) << 64),
479+
digits[2] as i128 | ((digits[3] as i128) << 64),
480480
)
481481
}
482482

@@ -746,7 +746,7 @@ impl Shl<u8> for i256 {
746746
self
747747
} else if rhs < 128 {
748748
Self {
749-
high: self.high << rhs | (self.low >> (128 - rhs)) as i128,
749+
high: (self.high << rhs) | (self.low >> (128 - rhs)) as i128,
750750
low: self.low << rhs,
751751
}
752752
} else {
@@ -768,7 +768,7 @@ impl Shr<u8> for i256 {
768768
} else if rhs < 128 {
769769
Self {
770770
high: self.high >> rhs,
771-
low: self.low >> rhs | ((self.high as u128) << (128 - rhs)),
771+
low: (self.low >> rhs) | ((self.high as u128) << (128 - rhs)),
772772
}
773773
} else {
774774
Self {

arrow-json/src/reader/decimal_array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ where
6666
}
6767
TapeElement::I64(high) => match tape.get(*p + 1) {
6868
TapeElement::I32(low) => {
69-
let val = ((high as i64) << 32 | (low as u32) as i64).to_string();
69+
let val = (((high as i64) << 32) | (low as u32) as i64).to_string();
7070
let value = parse_decimal::<D>(&val, self.precision, self.scale)?;
7171
builder.append_value(value)
7272
}
@@ -79,7 +79,7 @@ where
7979
}
8080
TapeElement::F64(high) => match tape.get(*p + 1) {
8181
TapeElement::F32(low) => {
82-
let val = f64::from_bits((high as u64) << 32 | low as u64).to_string();
82+
let val = f64::from_bits(((high as u64) << 32) | low as u64).to_string();
8383
let value = parse_decimal::<D>(&val, self.precision, self.scale)?;
8484
builder.append_value(value)
8585
}

arrow-json/src/reader/primitive_array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ where
132132
}
133133
TapeElement::F64(high) => match tape.get(p + 1) {
134134
TapeElement::F32(low) => {
135-
let v = f64::from_bits((high as u64) << 32 | low as u64);
135+
let v = f64::from_bits(((high as u64) << 32) | low as u64);
136136
let value = NumCast::from(v).ok_or_else(|| {
137137
ArrowError::JsonError(format!("failed to parse {v} as {d}",))
138138
})?;
@@ -142,7 +142,7 @@ where
142142
},
143143
TapeElement::I64(high) => match tape.get(p + 1) {
144144
TapeElement::I32(low) => {
145-
let v = (high as i64) << 32 | (low as u32) as i64;
145+
let v = ((high as i64) << 32) | (low as u32) as i64;
146146
let value = NumCast::from(v).ok_or_else(|| {
147147
ArrowError::JsonError(format!("failed to parse {v} as {d}",))
148148
})?;

arrow-json/src/reader/string_array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl<O: OffsetSizeTrait> ArrayDecoder for StringArrayDecoder<O> {
102102
}
103103
TapeElement::I64(high) if coerce_primitive => match tape.get(p + 1) {
104104
TapeElement::I32(low) => {
105-
let val = (high as i64) << 32 | (low as u32) as i64;
105+
let val = ((high as i64) << 32) | (low as u32) as i64;
106106
builder.append_value(val.to_string());
107107
}
108108
_ => unreachable!(),
@@ -115,7 +115,7 @@ impl<O: OffsetSizeTrait> ArrayDecoder for StringArrayDecoder<O> {
115115
}
116116
TapeElement::F64(high) if coerce_primitive => match tape.get(p + 1) {
117117
TapeElement::F32(low) => {
118-
let val = f64::from_bits((high as u64) << 32 | low as u64);
118+
let val = f64::from_bits(((high as u64) << 32) | low as u64);
119119
builder.append_value(val.to_string());
120120
}
121121
_ => unreachable!(),

arrow-json/src/reader/tape.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl<'a> Tape<'a> {
180180
TapeElement::Null => out.push_str("null"),
181181
TapeElement::I64(high) => match self.get(idx + 1) {
182182
TapeElement::I32(low) => {
183-
let val = (high as i64) << 32 | (low as u32) as i64;
183+
let val = ((high as i64) << 32) | (low as u32) as i64;
184184
let _ = write!(out, "{val}");
185185
return idx + 2;
186186
}
@@ -191,7 +191,7 @@ impl<'a> Tape<'a> {
191191
}
192192
TapeElement::F64(high) => match self.get(idx + 1) {
193193
TapeElement::F32(low) => {
194-
let val = f64::from_bits((high as u64) << 32 | low as u64);
194+
let val = f64::from_bits(((high as u64) << 32) | low as u64);
195195
let _ = write!(out, "{val}");
196196
return idx + 2;
197197
}
@@ -491,7 +491,7 @@ impl TapeDecoder {
491491
// Parse a unicode escape sequence
492492
DecoderState::Unicode(high, low, idx) => loop {
493493
match *idx {
494-
0..=3 => *high = *high << 4 | parse_hex(next!(iter))? as u16,
494+
0..=3 => *high = (*high << 4) | parse_hex(next!(iter))? as u16,
495495
4 => {
496496
if let Some(c) = char::from_u32(*high as u32) {
497497
write_char(c, &mut self.bytes);
@@ -508,7 +508,7 @@ impl TapeDecoder {
508508
b'u' => {}
509509
b => return Err(err(b, "parsing surrogate pair unicode")),
510510
},
511-
6..=9 => *low = *low << 4 | parse_hex(next!(iter))? as u16,
511+
6..=9 => *low = (*low << 4) | parse_hex(next!(iter))? as u16,
512512
_ => {
513513
let c = char_from_surrogate_pair(*low, *high)?;
514514
write_char(c, &mut self.bytes);
@@ -683,7 +683,7 @@ fn err(b: u8, ctx: &str) -> ArrowError {
683683

684684
/// Creates a character from an UTF-16 surrogate pair
685685
fn char_from_surrogate_pair(low: u16, high: u16) -> Result<char, ArrowError> {
686-
let n = (((high - 0xD800) as u32) << 10 | (low - 0xDC00) as u32) + 0x1_0000;
686+
let n = (((high - 0xD800) as u32) << 10) | ((low - 0xDC00) as u32 + 0x1_0000);
687687
char::from_u32(n)
688688
.ok_or_else(|| ArrowError::JsonError(format!("Invalid UTF-16 surrogate pair {n}")))
689689
}

arrow-json/src/reader/timestamp_array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ where
9797
TapeElement::I32(v) => builder.append_value(v as i64),
9898
TapeElement::I64(high) => match tape.get(p + 1) {
9999
TapeElement::I32(low) => {
100-
builder.append_value((high as i64) << 32 | (low as u32) as i64)
100+
builder.append_value(((high as i64) << 32) | (low as u32) as i64)
101101
}
102102
_ => unreachable!(),
103103
},

arrow-select/src/union_extract.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ fn eq_scalar_inner(chunk_size: usize, type_ids: &[i8], target: i8) -> BoolValue
341341
.copied()
342342
.enumerate()
343343
.fold(0, |packed, (bit_idx, v)| {
344-
packed | ((v == target) as u64) << bit_idx
344+
packed | (((v == target) as u64) << bit_idx)
345345
})
346346
}));
347347

parquet/src/encodings/rle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ mod tests {
938938

939939
// bit-packed header
940940
let run_bytes = ceil(num_values * bit_width, 8) as u64;
941-
writer.put_vlq_int(run_bytes << 1 | 1);
941+
writer.put_vlq_int((run_bytes << 1) | 1);
942942
for _ in 0..run_bytes {
943943
writer.put_aligned(0xFF_u8, 1);
944944
}

0 commit comments

Comments
 (0)