Skip to content

Commit

Permalink
arrow: enable clippy::vec_init_then_push lint
Browse files Browse the repository at this point in the history
  • Loading branch information
gsserge committed Feb 12, 2022
1 parent 8f7c56e commit 0eccb4a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
7 changes: 4 additions & 3 deletions arrow/src/array/array_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,10 @@ mod tests {
.build()
.unwrap();

let mut field_types = vec![];
field_types.push(Field::new("a", DataType::Boolean, false));
field_types.push(Field::new("b", DataType::Int32, false));
let field_types = vec![
Field::new("a", DataType::Boolean, false),
Field::new("b", DataType::Int32, false),
];
let struct_array_data = ArrayData::builder(DataType::Struct(field_types))
.len(5)
.add_child_data(boolean_data.clone())
Expand Down
21 changes: 11 additions & 10 deletions arrow/src/array/array_union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,16 +603,17 @@ mod tests {
let type_id_buffer = Buffer::from_slice_ref(&type_ids);
let value_offsets_buffer = Buffer::from_slice_ref(&value_offsets);

let mut children: Vec<(Field, Arc<dyn Array>)> = Vec::new();
children.push((
Field::new("A", DataType::Utf8, false),
Arc::new(string_array),
));
children.push((Field::new("B", DataType::Int32, false), Arc::new(int_array)));
children.push((
Field::new("C", DataType::Float64, false),
Arc::new(float_array),
));
let children: Vec<(Field, Arc<dyn Array>)> = vec![
(
Field::new("A", DataType::Utf8, false),
Arc::new(string_array),
),
(Field::new("B", DataType::Int32, false), Arc::new(int_array)),
(
Field::new("C", DataType::Float64, false),
Arc::new(float_array),
),
];
let array = UnionArray::try_new(
type_id_buffer,
Some(value_offsets_buffer),
Expand Down
17 changes: 9 additions & 8 deletions arrow/src/array/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3700,12 +3700,14 @@ mod tests {

#[test]
fn test_struct_array_builder_from_schema() {
let mut fields = Vec::new();
fields.push(Field::new("f1", DataType::Float32, false));
fields.push(Field::new("f2", DataType::Utf8, false));
let mut sub_fields = Vec::new();
sub_fields.push(Field::new("g1", DataType::Int32, false));
sub_fields.push(Field::new("g2", DataType::Boolean, false));
let mut fields = vec![
Field::new("f1", DataType::Float32, false),
Field::new("f2", DataType::Utf8, false),
];
let sub_fields = vec![
Field::new("g1", DataType::Int32, false),
Field::new("g2", DataType::Boolean, false),
];
let struct_type = DataType::Struct(sub_fields);
fields.push(Field::new("f3", struct_type, false));

Expand All @@ -3721,8 +3723,7 @@ mod tests {
expected = "Data type List(Field { name: \"item\", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: None }) is not currently supported"
)]
fn test_struct_array_builder_from_schema_unsupported_type() {
let mut fields = Vec::new();
fields.push(Field::new("f1", DataType::Int16, false));
let mut fields = vec![Field::new("f1", DataType::Int16, false)];
let list_type =
DataType::List(Box::new(Field::new("item", DataType::Int64, true)));
fields.push(Field::new("f2", list_type, false));
Expand Down
7 changes: 4 additions & 3 deletions arrow/src/compute/kernels/limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@ mod tests {
.build()
.unwrap();

let mut field_types = vec![];
field_types.push(Field::new("a", DataType::Boolean, false));
field_types.push(Field::new("b", DataType::Int32, false));
let field_types = vec![
Field::new("a", DataType::Boolean, false),
Field::new("b", DataType::Int32, false),
];
let struct_array_data = ArrayData::builder(DataType::Struct(field_types))
.len(5)
.add_child_data(boolean_data.clone())
Expand Down
1 change: 0 additions & 1 deletion arrow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@
// upper_case_acronyms lint was introduced in Rust 1.51.
// It is triggered in the ffi module, and ipc::gen, which we have no control over
clippy::upper_case_acronyms,
clippy::vec_init_then_push
)]
#![warn(missing_debug_implementations)]

Expand Down

0 comments on commit 0eccb4a

Please sign in to comment.