Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
62 changes: 62 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,37 +154,99 @@ broken_intra_doc_links = "warn"
missing_crate_level_docs = "warn"

[workspace.lints.clippy]
as_ptr_cast_mut = "warn"
assigning_clones = "warn"
bool_to_int_with_if = "warn"
checked_conversions = "warn"
clear_with_drain = "warn"
comparison_chain = "warn"
dbg_macro = "warn"
debug_assert_with_mut_call = "warn"
default_union_representation = "warn"
disallowed_script_idents = "warn"
doc_comment_double_space_linebreaks = "warn"
doc_include_without_cfg = "warn"
empty_enum_variants_with_brackets = "warn"
exit = "warn"
expl_impl_clone_on_copy = "warn"
explicit_deref_methods = "warn"
filter_map_next = "warn"
flat_map_option = "warn"
float_cmp_const = "warn"
fn_params_excessive_bools = "warn"
fn_to_numeric_cast_any = "warn"
format_push_string = "warn"
imprecise_flops = "warn"
inconsistent_struct_constructor = "warn"
index_refutable_slice = "warn"
inefficient_to_string = "warn"
infinite_loop = "warn"
into_iter_without_iter = "warn"
invalid_upcast_comparisons = "warn"
iter_filter_is_ok = "warn"
iter_filter_is_some = "warn"
iter_not_returning_iterator = "warn"
iter_on_empty_collections = "warn"
iter_with_drain = "warn"
large_digit_groups = "warn"
large_futures = "warn"
large_include_file = "warn"
large_stack_arrays = "warn"
large_stack_frames = "warn"
large_types_passed_by_value = "warn"
linkedlist = "warn"
literal_string_with_formatting_args = "warn"
lossy_float_literal = "warn"
macro_use_imports = "warn"
manual_instant_elapsed = "warn"
manual_is_power_of_two = "warn"
manual_midpoint = "warn"
match_wild_err_arm = "warn"
mismatching_type_param_order = "warn"
mut_mut = "warn"
mutex_integer = "warn"
negative_feature_names = "warn"
non_zero_suggestions = "warn"
nonstandard_macro_braces = "warn"
option_as_ref_cloned = "warn"
option_option = "warn"
path_buf_push_overwrite = "warn"
pathbuf_init_then_push = "warn"
ptr_cast_constness = "warn"
ptr_offset_by_literal = "warn"
pub_without_shorthand = "warn"
rc_mutex = "warn"
ref_binding_to_reference = "warn"
ref_option_ref = "warn"
rest_pat_in_fully_bound_structs = "warn"
same_functions_in_if_condition = "warn"
same_length_and_capacity = "warn"
set_contains_or_insert = "warn"
should_panic_without_expect = "warn"
single_char_pattern = "warn"
single_option_map = "warn"
stable_sort_primitive = "warn"
str_split_at_newline = "warn"
string_add_assign = "warn"
string_lit_chars_any = "warn"
suspicious_xor_used_as_pow = "warn"
todo = "warn"
trailing_empty_array = "warn"
trait_duplication_in_bounds = "warn"
transmute_ptr_to_ptr = "warn"
tuple_array_conversions = "warn"
uninhabited_references = "warn"
unnecessary_box_returns = "warn"
unnecessary_literal_bound = "warn"
unnecessary_safety_doc = "warn"
unnecessary_self_imports = "warn"
unnecessary_struct_initialization = "warn"
unused_async = "warn"
unused_peekable = "warn"
unused_rounding = "warn"
useless_let_if_seq = "warn"
verbose_file_reads = "warn"
wildcard_dependencies = "warn"
zero_sized_map_values = "warn"

# release inherited profile keeping debug information and symbols
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/array/byte_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,9 @@ impl<T: ByteArrayType> From<ArrayData> for GenericByteArray<T> {
// ArrayData is valid, and verified type above
let value_offsets = unsafe { get_offsets_from_buffer(offset_buffer, offset, len) };
Self {
data_type,
value_offsets,
value_data,
data_type,
nulls,
}
}
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/array/byte_view_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ impl<T: ByteViewType + ?Sized> GenericByteViewArray<T> {
total_len: current_elements,
});
}
debug_assert!(groups.len() <= i32::MAX as usize);
debug_assert!(i32::try_from(groups.len()).is_ok());

// Second pass: copy each group into an exactly-sized buffer.
let mut views_buf = Vec::with_capacity(len);
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/array/fixed_size_binary_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,9 @@ impl From<ArrayData> for FixedSizeBinaryArray {

Self {
data_type,
value_data,
nulls,
len,
value_data,
value_size,
}
}
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/builder/generic_bytes_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ impl<T: ByteArrayType> GenericByteBuilder<T> {
.unwrap_or_else(|| NullBufferBuilder::new_with_len(offsets_builder.len() - 1));

Self {
offsets_builder,
value_builder,
offsets_builder,
null_buffer_builder,
}
}
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 @@ -234,7 +234,7 @@ unsafe fn create_buffer(
if array.num_buffers() == 0 {
return None;
}
NonNull::new(array.buffer(index) as _)
NonNull::new(array.buffer(index).cast_mut())
.map(|ptr| unsafe { Buffer::from_custom_allocation(ptr, len, owner) })
}

Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ mod tests {
let mut items = Vec::with_capacity(iter.len());

let cb = |acc, item| {
items.push(CallArgs { item, acc });
items.push(CallArgs { acc, item });

item.map(|val| val + 100)
};
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/trusted_len.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ where
dst = unsafe { dst.add(1) };
}
assert_eq!(
unsafe { dst.offset_from(buffer.as_ptr() as *mut T) as usize },
unsafe { dst.offset_from(buffer.as_ptr().cast::<T>()) as usize },
upper,
"Trusted iterator length was not accurately reported"
);
Expand Down
4 changes: 2 additions & 2 deletions arrow-avro/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ impl AvroDataType {
resolution: Option<ResolutionInfo>,
) -> Self {
Self {
codec,
metadata,
nullability,
metadata,
codec,
resolution,
}
}
Expand Down
5 changes: 4 additions & 1 deletion arrow-avro/src/reader/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2330,7 +2330,10 @@ fn process_block_items(
total: usize,
on_item: &mut impl FnMut(&mut AvroCursor) -> Result<(), AvroError>,
) -> Result<usize, AvroError> {
let Some(new_total) = total.checked_add(count).filter(|&t| t <= i32::MAX as usize) else {
let Some(new_total) = total
.checked_add(count)
.filter(|&t| i32::try_from(t).is_ok())
else {
return Err(AvroError::ParseError(
"Capacity overflow when decoding array/map item blocks".to_string(),
));
Expand Down
6 changes: 3 additions & 3 deletions arrow-buffer/src/bigint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ impl i256 {
.wrapping_add(rhs.high as u128)
.wrapping_add(carry as u128) as i128;

let result = Self { high, low };
let result = Self { low, high };

// Signed overflow occurs when:
// - both operands have the same sign, and
Expand All @@ -792,7 +792,7 @@ impl i256 {
.wrapping_sub(rhs.high as u128)
.wrapping_sub(borrow as u128) as i128;

let result = Self { high, low };
let result = Self { low, high };

// Signed overflow occurs when:
// - operands have opposite signs, and
Expand Down Expand Up @@ -1812,7 +1812,7 @@ mod tests {
assert_eq!(v.to_f64().unwrap(), 42.0);

let v = i256::from_i128(-123456789012345678i128);
assert_eq!(v.to_f64().unwrap(), -123456789012345678.0);
assert_eq!(v.to_f64().unwrap(), -123_456_789_012_345_680.0);
Comment thread
emilk marked this conversation as resolved.

let v = i256::from_string("0").unwrap();
assert_eq!(v.to_f64().unwrap(), 0.0);
Expand Down
8 changes: 4 additions & 4 deletions arrow-buffer/src/buffer/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ impl MutableBuffer {
let byte_count = to_copy * bytes_per_copy;
unsafe {
// Get to the start of the data before we started copying anything
let src = self.data.as_ptr().add(length_before) as *const u8;
let src = self.data.as_ptr().add(length_before).cast_const();
// Go to the current location to copy to (end of current data)
let dst = self.data.as_ptr().add(self.len);
// SAFETY: the pointers are not overlapping as there is `byte_count` or less between them
Expand Down Expand Up @@ -963,10 +963,10 @@ impl<A: ArrowNativeType> Extend<A> for MutableBuffer {
}

impl<T: ArrowNativeType> From<Vec<T>> for MutableBuffer {
fn from(value: Vec<T>) -> Self {
fn from(mut value: Vec<T>) -> Self {
// Safety
// Vec::as_ptr guaranteed to not be null and ArrowNativeType are trivially transmutable
let data = unsafe { NonNull::new_unchecked(value.as_ptr() as _) };
// Vec::as_mut_ptr guaranteed to not be null and ArrowNativeType are trivially transmutable
let data = unsafe { NonNull::new_unchecked(value.as_mut_ptr().cast()) };
let len = value.len() * mem::size_of::<T>();
// Safety
// Vec guaranteed to have a valid layout matching that of `Layout::array`
Expand Down
4 changes: 2 additions & 2 deletions arrow-buffer/src/buffer/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ where

Self {
run_ends,
logical_offset,
logical_length,
logical_offset,
}
}

Expand All @@ -151,8 +151,8 @@ where
) -> Self {
Self {
run_ends,
logical_offset,
logical_length,
logical_offset,
}
}

Expand Down
4 changes: 3 additions & 1 deletion arrow-buffer/src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ impl From<bytes::Bytes> for Bytes {
let len = value.len();
Self {
len,
ptr: NonNull::new(value.as_ptr() as _).unwrap(),
// `bytes::Bytes` is shared and immutable, so the buffer is never written
// through this pointer; the cast only changes constness.
ptr: NonNull::new(value.as_ptr().cast_mut()).unwrap(),
deallocation: Deallocation::Custom(std::sync::Arc::new(value), len),
#[cfg(feature = "pool")]
reservation: Mutex::new(None),
Expand Down
4 changes: 4 additions & 0 deletions arrow-csv/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,10 @@ impl WriterBuilder {
}

#[cfg(test)]
#[expect(
clippy::verbose_file_reads,
reason = "`tempfile::tempfile()` has no path, so the contents can only be read back through the handle"
)]
mod tests {
use super::*;

Expand Down
2 changes: 1 addition & 1 deletion arrow-data/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2222,7 +2222,7 @@ impl ArrayDataBuilder {

/// Creates an `ArrayData`, consuming `self`
///
/// # Safety
/// # Undefined behavior
///
/// By default the underlying buffers are checked to ensure they are valid
/// Arrow data. However, if the [`Self::skip_validation`] flag has been set
Expand Down
20 changes: 3 additions & 17 deletions arrow-flight/gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@

//! Generates the Rust bindings for the Arrow Flight protobuf definitions.

use std::{
fs::OpenOptions,
io::{Read, Write},
path::Path,
};
use std::{fs::OpenOptions, io::Write, path::Path};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let proto_dir = Path::new("../format");
Expand All @@ -33,12 +29,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.out_dir("src")
.compile_with_config(prost_config(), &[proto_path], &[proto_dir])?;

// read file contents to string
let mut file = OpenOptions::new()
.read(true)
.open("src/arrow.flight.protocol.rs")?;
let mut buffer = String::new();
file.read_to_string(&mut buffer)?;
let buffer = std::fs::read_to_string("src/arrow.flight.protocol.rs")?;
// append warning that file was auto-generated
let mut file = OpenOptions::new()
.write(true)
Expand All @@ -56,12 +47,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.out_dir("src/sql")
.compile_with_config(prost_config(), &[proto_path], &[proto_dir])?;

// read file contents to string
let mut file = OpenOptions::new()
.read(true)
.open("src/sql/arrow.flight.protocol.sql.rs")?;
let mut buffer = String::new();
file.read_to_string(&mut buffer)?;
let buffer = std::fs::read_to_string("src/sql/arrow.flight.protocol.sql.rs")?;
// append warning that file was auto-generate
let mut file = OpenOptions::new()
.write(true)
Expand Down
4 changes: 4 additions & 0 deletions arrow-flight/src/sql/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,10 @@ where
}

/// Explicitly shut down and clean up the client.
#[expect(
clippy::unused_async,
reason = "public API: dropping `async` would break callers that `.await` it"
)]
pub async fn close(&mut self) -> Result<()> {
Comment thread
emilk marked this conversation as resolved.
// TODO: consume self instead of &mut self to explicitly prevent reuse?
Ok(())
Expand Down
7 changes: 1 addition & 6 deletions arrow-integration-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1272,9 +1272,6 @@ impl ArrowJsonBatch {
mod tests {
use super::*;

use std::fs::File;
use std::io::Read;

#[test]
fn test_schema_equality() {
let json = r#"
Expand Down Expand Up @@ -1596,9 +1593,7 @@ mod tests {
],
)
.unwrap();
let mut file = File::open("data/integration.json").unwrap();
let mut json = String::new();
file.read_to_string(&mut json).unwrap();
let json = std::fs::read_to_string("data/integration.json").unwrap();
let arrow_json: ArrowJson = serde_json::from_str(&json).unwrap();
// test schemas
assert!(arrow_json.schema.equals_schema(&schema));
Expand Down
Loading
Loading