Skip to content

Commit

Permalink
Fix clippy lints for Rust 1.54 (#631)
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb authored Jul 29, 2021
1 parent b46115b commit 2b2ec7e
Show file tree
Hide file tree
Showing 18 changed files with 63 additions and 62 deletions.
28 changes: 14 additions & 14 deletions arrow/src/array/equal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,11 @@ mod tests {
let a = a.data();
let b = NullArray::new(12);
let b = b.data();
test_equal(&a, &b, true);
test_equal(a, b, true);

let b = NullArray::new(10);
let b = b.data();
test_equal(&a, &b, false);
test_equal(a, b, false);

// Test the case where offset != 0

Expand All @@ -330,11 +330,11 @@ mod tests {
let a = a.data();
let b = BooleanArray::from(vec![false, false, true]);
let b = b.data();
test_equal(&a, &b, true);
test_equal(a, b, true);

let b = BooleanArray::from(vec![false, false, false]);
let b = b.data();
test_equal(&a, &b, false);
test_equal(a, b, false);
}

#[test]
Expand All @@ -343,15 +343,15 @@ mod tests {
let a = a.data();
let b = BooleanArray::from(vec![Some(false), None, None, Some(true)]);
let b = b.data();
test_equal(&a, &b, true);
test_equal(a, b, true);

let b = BooleanArray::from(vec![None, None, None, Some(true)]);
let b = b.data();
test_equal(&a, &b, false);
test_equal(a, b, false);

let b = BooleanArray::from(vec![Some(true), None, None, Some(true)]);
let b = b.data();
test_equal(&a, &b, false);
test_equal(a, b, false);
}

#[test]
Expand Down Expand Up @@ -382,15 +382,15 @@ mod tests {
let a = a.data();
let b = BooleanArray::from(vector.clone());
let b = b.data();
test_equal(&a, &b, true);
test_equal(a, b, true);

// Elements fill in `u8`s + suffix bits.
vector.push(true);
let a = BooleanArray::from(vector.clone());
let a = a.data();
let b = BooleanArray::from(vector);
let b = b.data();
test_equal(&a, &b, true);
test_equal(a, b, true);
}

#[test]
Expand Down Expand Up @@ -428,7 +428,7 @@ mod tests {
let lhs = lhs.data();
let rhs = Int32Array::from(rhs);
let rhs = rhs.data();
test_equal(&lhs, &rhs, expected);
test_equal(lhs, rhs, expected);
}
}

Expand Down Expand Up @@ -588,7 +588,7 @@ mod tests {
let b = StringArray::from(vec![Some("b")]);
let b = b.data();

test_equal(&a, &b, true);
test_equal(&a, b, true);
}

#[test]
Expand All @@ -609,11 +609,11 @@ mod tests {
let a = a.data();
let b = NullArray::new(2);
let b = b.data();
test_equal(&a, &b, true);
test_equal(a, b, true);

let b = NullArray::new(1);
let b = b.data();
test_equal(&a, &b, false);
test_equal(a, b, false);
}

fn create_list_array<U: AsRef<[i32]>, T: AsRef<[Option<U>]>>(data: T) -> ArrayData {
Expand Down Expand Up @@ -1016,7 +1016,7 @@ mod tests {
let b = StructArray::try_from(vec![("f1", strings), ("f2", ints)]).unwrap();
let b = b.data();

test_equal(&a, &b, true);
test_equal(a, b, true);
}

#[test]
Expand Down
12 changes: 6 additions & 6 deletions arrow/src/compute/kernels/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ mod tests {
assert_eq!(5, a.value(0));
assert_eq!(6, b.value(0));

let c = add(&a, &b).unwrap();
let c = add(a, b).unwrap();
assert_eq!(5, c.len());
assert_eq!(11, c.value(0));
assert_eq!(13, c.value(1));
Expand Down Expand Up @@ -1281,7 +1281,7 @@ mod tests {
let a = a.as_any().downcast_ref::<Int32Array>().unwrap();
let b = b.as_any().downcast_ref::<Int32Array>().unwrap();

let c = divide(&a, &b).unwrap();
let c = divide(a, b).unwrap();
assert_eq!(5, c.len());
assert_eq!(3, c.value(0));
assert_eq!(2, c.value(1));
Expand All @@ -1299,7 +1299,7 @@ mod tests {
let a = a.as_any().downcast_ref::<Int32Array>().unwrap();
let b = b.as_any().downcast_ref::<Int32Array>().unwrap();

let c = modulus(&a, &b).unwrap();
let c = modulus(a, b).unwrap();
assert_eq!(5, c.len());
assert_eq!(0, c.value(0));
assert_eq!(3, c.value(1));
Expand Down Expand Up @@ -1397,7 +1397,7 @@ mod tests {
let b = b.slice(8, 6);
let b = b.as_any().downcast_ref::<Int32Array>().unwrap();

let c = divide(&a, &b).unwrap();
let c = divide(a, b).unwrap();
assert_eq!(6, c.len());
assert_eq!(3, c.value(0));
assert!(c.is_null(1));
Expand Down Expand Up @@ -1450,7 +1450,7 @@ mod tests {
let b = b.slice(8, 6);
let b = b.as_any().downcast_ref::<Int32Array>().unwrap();

let c = modulus(&a, &b).unwrap();
let c = modulus(a, b).unwrap();
assert_eq!(6, c.len());
assert_eq!(0, c.value(0));
assert!(c.is_null(1));
Expand Down Expand Up @@ -1516,7 +1516,7 @@ mod tests {
let b = b.slice(63, 65);
let b = b.as_any().downcast_ref::<UInt8Array>().unwrap();

let actual = add(&a, &b).unwrap();
let actual = add(a, b).unwrap();
let actual: Vec<Option<u8>> = actual.iter().collect();
let expected: Vec<Option<u8>> = (63..63_u8 + 65_u8)
.into_iter()
Expand Down
14 changes: 7 additions & 7 deletions arrow/src/compute/kernels/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ mod tests {
let a = BooleanArray::from(vec![None, Some(true), Some(false), None, Some(true)]);
let a = a.slice(1, 4);
let a = a.as_any().downcast_ref::<BooleanArray>().unwrap();
let c = not(&a).unwrap();
let c = not(a).unwrap();

let expected =
BooleanArray::from(vec![Some(false), Some(true), None, Some(false)]);
Expand Down Expand Up @@ -883,7 +883,7 @@ mod tests {
let b = b.slice(8, 4);
let b = b.as_any().downcast_ref::<BooleanArray>().unwrap();

let c = and(&a, &b).unwrap();
let c = and(a, b).unwrap();

let expected = BooleanArray::from(vec![false, false, false, true]);

Expand All @@ -906,7 +906,7 @@ mod tests {
let b = b.slice(8, 4);
let b = b.as_any().downcast_ref::<BooleanArray>().unwrap();

let c = and(&a, &b).unwrap();
let c = and(a, b).unwrap();

let expected = BooleanArray::from(vec![false, false, false, true]);

Expand All @@ -924,7 +924,7 @@ mod tests {
let a = a.slice(8, 4);
let a = a.as_any().downcast_ref::<BooleanArray>().unwrap();

let c = and(&a, &b).unwrap();
let c = and(a, &b).unwrap();

let expected = BooleanArray::from(vec![false, false, false, true]);

Expand All @@ -942,7 +942,7 @@ mod tests {
let b = b.slice(8, 4);
let b = b.as_any().downcast_ref::<BooleanArray>().unwrap();

let c = and(&a, &b).unwrap();
let c = and(&a, b).unwrap();

let expected = BooleanArray::from(vec![false, false, false, true]);

Expand All @@ -967,7 +967,7 @@ mod tests {
let b = b.slice(2, 4);
let b = b.as_any().downcast_ref::<BooleanArray>().unwrap();

let c = and(&a, &b).unwrap();
let c = and(a, b).unwrap();

let expected =
BooleanArray::from(vec![Some(false), Some(false), None, Some(true)]);
Expand Down Expand Up @@ -1147,7 +1147,7 @@ mod tests {
]);
let comp = comp.slice(2, 3); // Some(false), None, Some(true)
let comp = comp.as_any().downcast_ref::<BooleanArray>().unwrap();
let res = nullif(&a, &comp).unwrap();
let res = nullif(a, comp).unwrap();

let expected = Int32Array::from(vec![
Some(15), // False => keep it
Expand Down
4 changes: 2 additions & 2 deletions arrow/src/compute/kernels/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3229,7 +3229,7 @@ mod tests {
where
T: ArrowNumericType,
{
let c = cast(&array, dt).unwrap();
let c = cast(array, dt).unwrap();
let a = c.as_any().downcast_ref::<PrimitiveArray<T>>().unwrap();
let mut v: Vec<String> = vec![];
for i in 0..array.len() {
Expand Down Expand Up @@ -3533,7 +3533,7 @@ mod tests {
for array in get_arrays_of_all_types() {
for to_type in &all_types {
println!("Test casting {:?} --> {:?}", array.data_type(), to_type);
let cast_result = cast(&array, &to_type);
let cast_result = cast(&array, to_type);
let reported_cast_ability = can_cast_types(array.data_type(), to_type);

// check for mismatch
Expand Down
2 changes: 1 addition & 1 deletion arrow/src/compute/kernels/cast_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ mod tests {
// Note: Use chrono APIs that are different than
// naive_datetime_to_timestamp to compute the utc offset to
// try and double check the logic
let utc_offset_secs = match Local.offset_from_local_datetime(&naive_datetime) {
let utc_offset_secs = match Local.offset_from_local_datetime(naive_datetime) {
LocalResult::Single(local_offset) => {
local_offset.fix().local_minus_utc() as i64
}
Expand Down
6 changes: 3 additions & 3 deletions arrow/src/compute/kernels/comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ mod tests {
let b = Int32Array::from(vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
let b_slice = b.slice(5, 5);
let c = b_slice.as_any().downcast_ref().unwrap();
let d = eq(&c, &a).unwrap();
let d = eq(c, &a).unwrap();
assert!(d.value(0));
assert!(d.value(1));
assert!(d.value(2));
Expand Down Expand Up @@ -1238,7 +1238,7 @@ mod tests {
let b: Int32Array = (100..200).map(Some).collect();
let b = b.slice(50, 50);
let b = b.as_any().downcast_ref::<Int32Array>().unwrap();
let actual = lt(&a, &b).unwrap();
let actual = lt(a, b).unwrap();
let expected: BooleanArray = (0..50).map(|_| Some(true)).collect();
assert_eq!(expected, actual);
}
Expand All @@ -1248,7 +1248,7 @@ mod tests {
let a: Int32Array = (0..100).map(Some).collect();
let a = a.slice(50, 50);
let a = a.as_any().downcast_ref::<Int32Array>().unwrap();
let actual = lt_scalar(&a, 200).unwrap();
let actual = lt_scalar(a, 200).unwrap();
let expected: BooleanArray = (0..50).map(|_| Some(true)).collect();
assert_eq!(expected, actual);
}
Expand Down
6 changes: 3 additions & 3 deletions arrow/src/compute/kernels/take.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ mod tests {

test_take_primitive_arrays_non_null::<Int64Type>(
vec![0, 10, 20, 30, 40, 50],
&index,
index,
None,
vec![Some(20), Some(30), None, None],
)
Expand All @@ -1036,7 +1036,7 @@ mod tests {

test_take_primitive_arrays::<Int64Type>(
vec![None, None, Some(20), Some(30), Some(40), Some(50)],
&index,
index,
None,
vec![Some(20), Some(30), None, None],
)
Expand Down Expand Up @@ -1291,7 +1291,7 @@ mod tests {
// boolean
test_take_boolean_arrays(
vec![Some(false), None, Some(true), Some(false), None],
&index,
index,
None,
vec![None, Some(false), Some(true), None],
);
Expand Down
8 changes: 4 additions & 4 deletions arrow/src/datatypes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,11 +796,11 @@ mod tests {
"Key": "Value"
}
}"#;
let value: Value = serde_json::from_str(&json).unwrap();
let value: Value = serde_json::from_str(json).unwrap();
assert_eq!(expected, value);

// convert back to a schema
let value: Value = serde_json::from_str(&json).unwrap();
let value: Value = serde_json::from_str(json).unwrap();
let schema2 = Schema::from(&value).unwrap();

assert_eq!(schema, schema2);
Expand All @@ -819,7 +819,7 @@ mod tests {
],
"metadata": {}
}"#;
let value: Value = serde_json::from_str(&json).unwrap();
let value: Value = serde_json::from_str(json).unwrap();
let schema = Schema::from(&value).unwrap();
assert!(schema.metadata.is_empty());

Expand All @@ -836,7 +836,7 @@ mod tests {
}
]
}"#;
let value: Value = serde_json::from_str(&json).unwrap();
let value: Value = serde_json::from_str(json).unwrap();
let schema = Schema::from(&value).unwrap();
assert!(schema.metadata.is_empty());
}
Expand Down
4 changes: 2 additions & 2 deletions arrow/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ mod tests {

// perform some operation
let array = array.as_any().downcast_ref::<Int32Array>().unwrap();
let array = kernels::arithmetic::add(&array, &array).unwrap();
let array = kernels::arithmetic::add(array, array).unwrap();

// verify
assert_eq!(array, Int32Array::from(vec![2, 4, 6]));
Expand Down Expand Up @@ -982,7 +982,7 @@ mod tests {

// perform some operation
let array = array.as_any().downcast_ref::<BooleanArray>().unwrap();
let array = kernels::boolean::not(&array)?;
let array = kernels::boolean::not(array)?;

// verify
assert_eq!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ async fn send_batch(
options: &writer::IpcWriteOptions,
) -> Result {
let (dictionary_flight_data, mut batch_flight_data) =
arrow_flight::utils::flight_data_from_arrow_batch(batch, &options);
arrow_flight::utils::flight_data_from_arrow_batch(batch, options);

upload_tx
.send_all(&mut stream::iter(dictionary_flight_data).map(Ok))
Expand Down Expand Up @@ -166,7 +166,7 @@ async fn verify_data(
consume_flight_location(
location,
ticket.clone(),
&expected_data,
expected_data,
expected_schema.clone(),
)
.await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ async fn record_batch_from_message(
data_body,
ipc_batch,
schema_ref,
&dictionaries_by_field,
dictionaries_by_field,
);

arrow_batch_result.map_err(|e| {
Expand Down
Loading

0 comments on commit 2b2ec7e

Please sign in to comment.