Skip to content

Commit 153085f

Browse files
alambjimexist
andauthored
Backport clippy fixes to active release (#475)
* fix clippy warnings for rust 1.53 (#470) * fix clippy warnings for rust 1.53 * update readme * Fix up Co-authored-by: Jiayu Liu <Jimexist@users.noreply.github.com>
1 parent 1f7f4bc commit 153085f

33 files changed

+317
-339
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ By default, `cargo test` will look for these directories at their
111111
standard location. The following environment variables can be used to override the location:
112112

113113
```bash
114-
# Optionaly specify a different location for test data
114+
# Optionally specify a different location for test data
115115
export PARQUET_TEST_DATA=$(cd ../parquet-testing/data; pwd)
116116
export ARROW_TEST_DATA=$(cd ../testing/data; pwd)
117117
```
@@ -147,7 +147,7 @@ We recommend using `clippy` for checking lints during development. While we do n
147147

148148
Run the following to check for clippy lints.
149149

150-
```
150+
```bash
151151
cargo clippy
152152
```
153153

@@ -175,7 +175,7 @@ ls -l .git/hooks/pre-commit
175175
If the file already exists, to avoid mistakenly **overriding**, you MAY have to check
176176
the link source or file content. Else if not exist, let's safely soft link [pre-commit.sh](pre-commit.sh) as file `.git/hooks/pre-commit`:
177177

178-
```
178+
```bash
179179
ln -s ../../rust/pre-commit.sh .git/hooks/pre-commit
180180
```
181181

arrow/src/array/array_binary.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -972,11 +972,11 @@ mod tests {
972972
assert_eq!(array.value(1), b"two");
973973
assert_eq!(array.value(3), b"");
974974
assert_eq!(array.value(4), b"three");
975-
assert_eq!(array.is_null(0), false);
976-
assert_eq!(array.is_null(1), false);
977-
assert_eq!(array.is_null(2), true);
978-
assert_eq!(array.is_null(3), false);
979-
assert_eq!(array.is_null(4), false);
975+
assert!(!array.is_null(0));
976+
assert!(!array.is_null(1));
977+
assert!(array.is_null(2));
978+
assert!(!array.is_null(3));
979+
assert!(!array.is_null(4));
980980
}
981981

982982
#[test]

arrow/src/array/array_boolean.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl From<Vec<bool>> for BooleanArray {
147147

148148
impl From<Vec<Option<bool>>> for BooleanArray {
149149
fn from(data: Vec<Option<bool>>) -> Self {
150-
BooleanArray::from_iter(data.iter())
150+
data.iter().collect()
151151
}
152152
}
153153

arrow/src/array/array_dictionary.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,12 @@ mod tests {
394394
assert_eq!(&DataType::Int32, keys.data_type());
395395
assert_eq!(3, keys.null_count());
396396

397-
assert_eq!(true, keys.is_valid(0));
398-
assert_eq!(false, keys.is_valid(1));
399-
assert_eq!(true, keys.is_valid(2));
400-
assert_eq!(false, keys.is_valid(3));
401-
assert_eq!(false, keys.is_valid(4));
402-
assert_eq!(true, keys.is_valid(5));
397+
assert!(keys.is_valid(0));
398+
assert!(!keys.is_valid(1));
399+
assert!(keys.is_valid(2));
400+
assert!(!keys.is_valid(3));
401+
assert!(!keys.is_valid(4));
402+
assert!(keys.is_valid(5));
403403

404404
assert_eq!(0, keys.value(0));
405405
assert_eq!(1, keys.value(2));

arrow/src/array/array_primitive.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -777,19 +777,19 @@ mod tests {
777777

778778
let bool_arr = arr2.as_any().downcast_ref::<BooleanArray>().unwrap();
779779

780-
assert_eq!(false, bool_arr.is_valid(0));
780+
assert!(!bool_arr.is_valid(0));
781781

782-
assert_eq!(true, bool_arr.is_valid(1));
783-
assert_eq!(true, bool_arr.value(1));
782+
assert!(bool_arr.is_valid(1));
783+
assert!(bool_arr.value(1));
784784

785-
assert_eq!(true, bool_arr.is_valid(2));
786-
assert_eq!(false, bool_arr.value(2));
785+
assert!(bool_arr.is_valid(2));
786+
assert!(!bool_arr.value(2));
787787

788-
assert_eq!(true, bool_arr.is_valid(3));
789-
assert_eq!(true, bool_arr.value(3));
788+
assert!(bool_arr.is_valid(3));
789+
assert!(bool_arr.value(3));
790790

791-
assert_eq!(true, bool_arr.is_valid(4));
792-
assert_eq!(false, bool_arr.value(4));
791+
assert!(bool_arr.is_valid(4));
792+
assert!(!bool_arr.value(4));
793793
}
794794

795795
#[test]

arrow/src/array/array_struct.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,12 +465,12 @@ mod tests {
465465
assert_eq!(5, c0.len());
466466
assert_eq!(3, c0.null_count());
467467
assert!(c0.is_valid(0));
468-
assert_eq!(false, c0.value(0));
468+
assert!(!c0.value(0));
469469
assert!(c0.is_null(1));
470470
assert!(c0.is_null(2));
471471
assert!(c0.is_null(3));
472472
assert!(c0.is_valid(4));
473-
assert_eq!(true, c0.value(4));
473+
assert!(c0.value(4));
474474

475475
let c1 = struct_array.column(1);
476476
let c1 = c1.as_any().downcast_ref::<Int32Array>().unwrap();
@@ -500,7 +500,7 @@ mod tests {
500500
assert!(sliced_c0.is_null(0));
501501
assert!(sliced_c0.is_null(1));
502502
assert!(sliced_c0.is_valid(2));
503-
assert_eq!(true, sliced_c0.value(2));
503+
assert!(sliced_c0.value(2));
504504

505505
let sliced_c1 = sliced_array.column(1);
506506
let sliced_c1 = sliced_c1.as_any().downcast_ref::<Int32Array>().unwrap();

arrow/src/array/array_union.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ mod tests {
390390

391391
assert_eq!(expected_array_values.len(), union.len());
392392
for (i, expected_value) in expected_array_values.iter().enumerate() {
393-
assert_eq!(false, union.is_null(i));
393+
assert!(!union.is_null(i));
394394
let slot = union.value(i);
395395
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
396396
assert_eq!(slot.len(), 1);
@@ -412,7 +412,7 @@ mod tests {
412412
assert_eq!(5, union.len());
413413
for i in 0..union.len() {
414414
let slot = union.value(i);
415-
assert_eq!(false, union.is_null(i));
415+
assert!(!union.is_null(i));
416416
match i {
417417
0 => {
418418
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
@@ -465,29 +465,29 @@ mod tests {
465465
match i {
466466
0 => {
467467
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
468-
assert_eq!(false, union.is_null(i));
468+
assert!(!union.is_null(i));
469469
assert_eq!(slot.len(), 1);
470470
let value = slot.value(0);
471471
assert_eq!(1_i32, value);
472472
}
473473
1 => {
474474
let slot = slot.as_any().downcast_ref::<Int64Array>().unwrap();
475-
assert_eq!(false, union.is_null(i));
475+
assert!(!union.is_null(i));
476476
assert_eq!(slot.len(), 1);
477477
let value = slot.value(0);
478478
assert_eq!(3_i64, value);
479479
}
480480
2 => {
481481
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
482-
assert_eq!(false, union.is_null(i));
482+
assert!(!union.is_null(i));
483483
assert_eq!(slot.len(), 1);
484484
let value = slot.value(0);
485485
assert_eq!(10_i32, value);
486486
}
487487
3 => assert!(union.is_null(i)),
488488
4 => {
489489
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
490-
assert_eq!(false, union.is_null(i));
490+
assert!(!union.is_null(i));
491491
assert_eq!(slot.len(), 1);
492492
let value = slot.value(0);
493493
assert_eq!(6_i32, value);
@@ -516,15 +516,15 @@ mod tests {
516516
match i {
517517
0 => {
518518
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
519-
assert_eq!(false, union.is_null(i));
519+
assert!(!union.is_null(i));
520520
assert_eq!(slot.len(), 1);
521521
let value = slot.value(0);
522522
assert_eq!(10_i32, value);
523523
}
524524
1 => assert!(new_union.is_null(i)),
525525
2 => {
526526
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
527-
assert_eq!(false, union.is_null(i));
527+
assert!(!union.is_null(i));
528528
assert_eq!(slot.len(), 1);
529529
let value = slot.value(0);
530530
assert_eq!(6_i32, value);
@@ -666,7 +666,7 @@ mod tests {
666666

667667
assert_eq!(expected_array_values.len(), union.len());
668668
for (i, expected_value) in expected_array_values.iter().enumerate() {
669-
assert_eq!(false, union.is_null(i));
669+
assert!(!union.is_null(i));
670670
let slot = union.value(i);
671671
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
672672
assert_eq!(slot.len(), 1);
@@ -701,7 +701,7 @@ mod tests {
701701

702702
for i in 0..union.len() {
703703
let slot = union.value(i);
704-
assert_eq!(false, union.is_null(i));
704+
assert!(!union.is_null(i));
705705
match i {
706706
0 => {
707707
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
@@ -766,22 +766,22 @@ mod tests {
766766
match i {
767767
0 => {
768768
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
769-
assert_eq!(false, union.is_null(i));
769+
assert!(!union.is_null(i));
770770
assert_eq!(slot.len(), 1);
771771
let value = slot.value(0);
772772
assert_eq!(1_i32, value);
773773
}
774774
1 => assert!(union.is_null(i)),
775775
2 => {
776776
let slot = slot.as_any().downcast_ref::<Float64Array>().unwrap();
777-
assert_eq!(false, union.is_null(i));
777+
assert!(!union.is_null(i));
778778
assert_eq!(slot.len(), 1);
779779
let value = slot.value(0);
780780
assert!(value - 3_f64 < f64::EPSILON);
781781
}
782782
3 => {
783783
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
784-
assert_eq!(false, union.is_null(i));
784+
assert!(!union.is_null(i));
785785
assert_eq!(slot.len(), 1);
786786
let value = slot.value(0);
787787
assert_eq!(4_i32, value);
@@ -811,15 +811,15 @@ mod tests {
811811
0 => assert!(new_union.is_null(i)),
812812
1 => {
813813
let slot = slot.as_any().downcast_ref::<Float64Array>().unwrap();
814-
assert_eq!(false, new_union.is_null(i));
814+
assert!(!new_union.is_null(i));
815815
assert_eq!(slot.len(), 1);
816816
let value = slot.value(0);
817817
assert!(value - 3_f64 < f64::EPSILON);
818818
}
819819
2 => assert!(new_union.is_null(i)),
820820
3 => {
821821
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
822-
assert_eq!(false, new_union.is_null(i));
822+
assert!(!new_union.is_null(i));
823823
assert_eq!(slot.len(), 1);
824824
let value = slot.value(0);
825825
assert_eq!(4_i32, value);

arrow/src/array/builder.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,11 +2264,11 @@ mod tests {
22642264
assert_eq!(a.len(), 7);
22652265
let array = a.finish();
22662266
assert_eq!(array.value(0), 1);
2267-
assert_eq!(array.is_null(1), true);
2267+
assert!(array.is_null(1));
22682268
assert_eq!(array.value(2), -2);
22692269
assert_eq!(array.value(3), 1);
22702270
assert_eq!(array.value(4), 2);
2271-
assert_eq!(array.is_null(5), true);
2271+
assert!(array.is_null(5));
22722272
assert_eq!(array.value(6), 4);
22732273

22742274
Ok(())
@@ -3201,9 +3201,9 @@ mod tests {
32013201
let ava: &UInt32Array = av.as_any().downcast_ref::<UInt32Array>().unwrap();
32023202
let avs: &[u32] = ava.values();
32033203

3204-
assert_eq!(array.is_null(0), false);
3205-
assert_eq!(array.is_null(1), true);
3206-
assert_eq!(array.is_null(2), false);
3204+
assert!(!array.is_null(0));
3205+
assert!(array.is_null(1));
3206+
assert!(!array.is_null(2));
32073207

32083208
assert_eq!(avs, &[12345678, 22345678]);
32093209
}
@@ -3258,7 +3258,7 @@ mod tests {
32583258
let av = array.values();
32593259
let ava: &StringArray = av.as_any().downcast_ref::<StringArray>().unwrap();
32603260

3261-
assert_eq!(ava.is_valid(0), false);
3261+
assert!(!ava.is_valid(0));
32623262
assert_eq!(ava.value(1), "def");
32633263
assert_eq!(ava.value(2), "abc");
32643264
assert_eq!(ava.value(3), "ghi");
@@ -3279,13 +3279,13 @@ mod tests {
32793279
builder.append("abc").unwrap();
32803280
let array = builder.finish();
32813281

3282-
assert_eq!(array.is_null(1), true);
3283-
assert_eq!(array.is_valid(1), false);
3282+
assert!(array.is_null(1));
3283+
assert!(!array.is_valid(1));
32843284

32853285
let keys = array.keys_array();
32863286

32873287
assert_eq!(keys.value(0), 1);
3288-
assert_eq!(keys.is_null(1), true);
3288+
assert!(keys.is_null(1));
32893289
// zero initialization is currently guaranteed by Buffer allocation and resizing
32903290
assert_eq!(keys.value(1), 0);
32913291
assert_eq!(keys.value(2), 2);

arrow/src/array/equal/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -361,18 +361,18 @@ mod tests {
361361
let b =
362362
BooleanArray::from(vec![true, false, false, false, true, false, true, true]);
363363
let b = b.data();
364-
assert_eq!(equal(a, b), false);
365-
assert_eq!(equal(b, a), false);
364+
assert!(!equal(a, b));
365+
assert!(!equal(b, a));
366366

367367
let a_slice = a.slice(2, 3);
368368
let b_slice = b.slice(3, 3);
369-
assert_eq!(equal(&a_slice, &b_slice), true);
370-
assert_eq!(equal(&b_slice, &a_slice), true);
369+
assert!(equal(&a_slice, &b_slice));
370+
assert!(equal(&b_slice, &a_slice));
371371

372372
let a_slice = a.slice(3, 4);
373373
let b_slice = b.slice(4, 4);
374-
assert_eq!(equal(&a_slice, &b_slice), false);
375-
assert_eq!(equal(&b_slice, &a_slice), false);
374+
assert!(!equal(&a_slice, &b_slice));
375+
assert!(!equal(&b_slice, &a_slice));
376376

377377
// Test the optimization cases where null_count == 0 and starts at 0 and len >= size_of(u8)
378378

@@ -486,8 +486,8 @@ mod tests {
486486

487487
fn test_equal(lhs: &ArrayData, rhs: &ArrayData, expected: bool) {
488488
// equality is symmetric
489-
assert_eq!(equal(lhs, lhs), true, "\n{:?}\n{:?}", lhs, lhs);
490-
assert_eq!(equal(rhs, rhs), true, "\n{:?}\n{:?}", rhs, rhs);
489+
assert!(equal(lhs, lhs), "\n{:?}\n{:?}", lhs, lhs);
490+
assert!(equal(rhs, rhs), "\n{:?}\n{:?}", rhs, rhs);
491491

492492
assert_eq!(equal(lhs, rhs), expected, "\n{:?}\n{:?}", lhs, rhs);
493493
assert_eq!(equal(rhs, lhs), expected, "\n{:?}\n{:?}", rhs, lhs);

arrow/src/array/null.rs

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

133133
assert_eq!(null_arr.len(), 32);
134134
assert_eq!(null_arr.null_count(), 32);
135-
assert_eq!(null_arr.is_valid(0), false);
135+
assert!(!null_arr.is_valid(0));
136136

137137
assert_eq!(0, null_arr.get_buffer_memory_size());
138138
assert_eq!(

0 commit comments

Comments
 (0)