This is an automated email from the ASF dual-hosted git repository.
Jefffrey pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new a5845cc14b Enable `allow_attributes` lint for `arrow-ipc` (#10700)
a5845cc14b is described below
commit a5845cc14b23dc680115c6b1e7e8dd2f724a0631
Author: WaterWhisperer <[email protected]>
AuthorDate: Sat Aug 15 23:00:47 2026 +0800
Enable `allow_attributes` lint for `arrow-ipc` (#10700)
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax.
-->
- Part of #10458.
# Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->
Enable `clippy::allow_attributes` for `arrow-ipc`
# What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->
- Enable `clippy::allow_attributes` for `arrow-ipc`.
- Replace active `allow` with `expect` attributes.
# Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
If this PR claims a performance improvement, please include evidence
such as benchmark results.
-->
Yes.
`cargo clippy --workspace --all-targets --all-features -- -D warnings`
# Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
If there are any breaking changes to public APIs, please call them out.
-->
No.
---
arrow-ipc/src/compression.rs | 6 +-----
arrow-ipc/src/convert.rs | 6 +++---
arrow-ipc/src/lib.rs | 3 +++
arrow-ipc/src/reader.rs | 22 +++++++++++-----------
arrow-ipc/src/reader/stream.rs | 2 +-
arrow-ipc/src/writer.rs | 22 ++++++++++------------
6 files changed, 29 insertions(+), 32 deletions(-)
diff --git a/arrow-ipc/src/compression.rs b/arrow-ipc/src/compression.rs
index 8154d23ab2..176ad726a6 100644
--- a/arrow-ipc/src/compression.rs
+++ b/arrow-ipc/src/compression.rs
@@ -110,7 +110,7 @@ impl DecompressionContext {
}
}
-#[allow(clippy::derivable_impls)]
+#[expect(clippy::derivable_impls)]
impl Default for DecompressionContext {
fn default() -> Self {
DecompressionContext {
@@ -300,7 +300,6 @@ fn compress_lz4(input: &[u8], output: &mut Vec<u8>) ->
Result<(), ArrowError> {
}
#[cfg(not(feature = "lz4"))]
-#[allow(clippy::ptr_arg)]
fn compress_lz4(_input: &[u8], _output: &mut Vec<u8>) -> Result<(),
ArrowError> {
Err(ArrowError::InvalidArgumentError(
"lz4 IPC compression requires the lz4 feature".to_string(),
@@ -316,7 +315,6 @@ fn decompress_lz4(input: &[u8], decompressed_size: usize)
-> Result<Vec<u8>, Arr
}
#[cfg(not(feature = "lz4"))]
-#[allow(clippy::ptr_arg)]
fn decompress_lz4(_input: &[u8], _decompressed_size: usize) -> Result<Vec<u8>,
ArrowError> {
Err(ArrowError::InvalidArgumentError(
"lz4 IPC decompression requires the lz4 feature".to_string(),
@@ -336,7 +334,6 @@ fn compress_zstd(
}
#[cfg(not(feature = "zstd"))]
-#[allow(clippy::ptr_arg)]
fn compress_zstd(
_input: &[u8],
_output: &mut Vec<u8>,
@@ -361,7 +358,6 @@ fn decompress_zstd(
}
#[cfg(not(feature = "zstd"))]
-#[allow(clippy::ptr_arg)]
fn decompress_zstd(
_input: &[u8],
_decompressed_size: usize,
diff --git a/arrow-ipc/src/convert.rs b/arrow-ipc/src/convert.rs
index 7e1fc962f4..d422704ec8 100644
--- a/arrow-ipc/src/convert.rs
+++ b/arrow-ipc/src/convert.rs
@@ -170,7 +170,7 @@ impl From<crate::Field<'_>> for Field {
/// Convert an IPC Field to Arrow Field
fn try_field_from(field: crate::Field) -> Result<Field, ArrowError> {
let arrow_field = if let Some(dictionary) = field.dictionary() {
- #[allow(deprecated)]
+ #[expect(deprecated)]
Field::new_dict(
field.name().unwrap_or_default(),
get_data_type(field, true)?,
@@ -1352,7 +1352,7 @@ mod tests {
),
true,
),
- #[allow(deprecated)]
+ #[expect(deprecated)]
Field::new_dict(
"dictionary<int32, utf8>",
DataType::Dictionary(Box::new(DataType::Int32),
Box::new(DataType::Utf8)),
@@ -1360,7 +1360,7 @@ mod tests {
123,
true,
),
- #[allow(deprecated)]
+ #[expect(deprecated)]
Field::new_dict(
"dictionary<uint8, uint32>",
DataType::Dictionary(Box::new(DataType::UInt8),
Box::new(DataType::UInt32)),
diff --git a/arrow-ipc/src/lib.rs b/arrow-ipc/src/lib.rs
index 64ea4f2643..54a75d0b96 100644
--- a/arrow-ipc/src/lib.rs
+++ b/arrow-ipc/src/lib.rs
@@ -43,6 +43,7 @@
html_favicon_url =
"https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_transparent-bg.svg"
)]
#![cfg_attr(docsrs, feature(doc_cfg))]
+#![deny(clippy::allow_attributes)]
#![warn(missing_docs)]
pub mod convert;
pub mod reader;
@@ -53,6 +54,8 @@ mod compression;
#[cfg(test)]
mod tests;
+// This code is generated so we don't want to fix any lint violations manually
+#[allow(clippy::allow_attributes)]
#[allow(mismatched_lifetime_syntaxes)]
#[allow(clippy::redundant_closure)]
#[allow(clippy::needless_lifetimes)]
diff --git a/arrow-ipc/src/reader.rs b/arrow-ipc/src/reader.rs
index c0d99c370e..f501e4c344 100644
--- a/arrow-ipc/src/reader.rs
+++ b/arrow-ipc/src/reader.rs
@@ -175,7 +175,7 @@ impl RecordBatchDecoder<'_> {
let index_node = self.next_node(field)?;
let index_buffers = [self.next_buffer()?, self.next_buffer()?];
- #[allow(deprecated)]
+ #[expect(deprecated)]
let dict_id = field.dict_id().ok_or_else(|| {
ArrowError::ParseError(format!("Field {field} does not
have dict id"))
})?;
@@ -876,7 +876,7 @@ fn get_dictionary_values(
skip_validation: UnsafeFlag,
) -> Result<ArrayRef, ArrowError> {
let id = batch.id();
- #[allow(deprecated)]
+ #[expect(deprecated)]
let fields_using_this_dictionary = schema.fields_with_dict_id(id);
let first_field = fields_using_this_dictionary.first().ok_or_else(|| {
ArrowError::InvalidArgumentError(format!("dictionary id {id} not found
in schema"))
@@ -1799,7 +1799,7 @@ impl<R: Read> RecordBatchReader for StreamReader<R> {
/// batch or dictionary batch requires access to stream state such as schema
/// and the full dictionary cache.
#[derive(Debug)]
-#[allow(dead_code)]
+#[expect(dead_code)]
pub(crate) enum IpcMessage {
Schema(arrow_schema::Schema),
RecordBatch(RecordBatch),
@@ -2857,7 +2857,7 @@ mod tests {
let key_dict_keys = Int8Array::from_iter_values([0, 0, 2, 2, 2, 3]);
let key_dict_array = DictionaryArray::new(key_dict_keys, values);
- #[allow(deprecated)]
+ #[expect(deprecated)]
let keys_field = Arc::new(Field::new_dict(
Field::MAP_KEY_FIELD_DEFAULT_NAME,
DataType::Dictionary(Box::new(DataType::Int8),
Box::new(DataType::Utf8)),
@@ -2865,7 +2865,7 @@ mod tests {
1,
false,
));
- #[allow(deprecated)]
+ #[expect(deprecated)]
let values_field = Arc::new(Field::new_dict(
Field::MAP_VALUE_FIELD_DEFAULT_NAME,
DataType::Dictionary(Box::new(DataType::Int8),
Box::new(DataType::Utf8)),
@@ -2946,7 +2946,7 @@ mod tests {
#[test]
fn test_roundtrip_stream_dict_of_list_of_dict() {
// list
- #[allow(deprecated)]
+ #[expect(deprecated)]
let list_data_type = DataType::List(Arc::new(Field::new_dict(
"item",
DataType::Dictionary(Box::new(DataType::Int8),
Box::new(DataType::Utf8)),
@@ -2958,7 +2958,7 @@ mod tests {
test_roundtrip_stream_dict_of_list_of_dict_impl::<i32,
i32>(list_data_type, offsets);
// large list
- #[allow(deprecated)]
+ #[expect(deprecated)]
let list_data_type = DataType::LargeList(Arc::new(Field::new_dict(
"item",
DataType::Dictionary(Box::new(DataType::Int8),
Box::new(DataType::Utf8)),
@@ -2977,7 +2977,7 @@ mod tests {
let dict_array = DictionaryArray::new(keys, Arc::new(values));
let dict_data = dict_array.into_data();
- #[allow(deprecated)]
+ #[expect(deprecated)]
let list_data_type = DataType::FixedSizeList(
Arc::new(Field::new_dict(
"item",
@@ -3068,7 +3068,7 @@ mod tests {
let key_dict_keys = Int8Array::from_iter_values([0, 0, 2, 2, 0, 2, 3]);
let key_dict_array = DictionaryArray::new(key_dict_keys,
utf8_view_array.clone());
- #[allow(deprecated)]
+ #[expect(deprecated)]
let keys_field = Arc::new(Field::new_dict(
Field::MAP_KEY_FIELD_DEFAULT_NAME,
DataType::Dictionary(Box::new(DataType::Int8),
Box::new(DataType::Utf8View)),
@@ -3079,7 +3079,7 @@ mod tests {
let value_dict_keys = Int8Array::from_iter_values([0, 3, 0, 1, 2, 0,
1]);
let value_dict_array = DictionaryArray::new(value_dict_keys,
bin_view_array);
- #[allow(deprecated)]
+ #[expect(deprecated)]
let values_field = Arc::new(Field::new_dict(
Field::MAP_VALUE_FIELD_DEFAULT_NAME,
DataType::Dictionary(Box::new(DataType::Int8),
Box::new(DataType::BinaryView)),
@@ -3465,7 +3465,7 @@ mod tests {
["a", "b"]
.iter()
.map(|name| {
- #[allow(deprecated)]
+ #[expect(deprecated)]
Field::new_dict(
name.to_string(),
DataType::Dictionary(
diff --git a/arrow-ipc/src/reader/stream.rs b/arrow-ipc/src/reader/stream.rs
index 10c45745ca..7efb202ed7 100644
--- a/arrow-ipc/src/reader/stream.rs
+++ b/arrow-ipc/src/reader/stream.rs
@@ -386,7 +386,7 @@ mod tests {
"test1",
DataType::RunEndEncoded(
Arc::new(Field::new("run_ends".to_string(), DataType::Int32,
false)),
- #[allow(deprecated)]
+ #[expect(deprecated)]
Arc::new(Field::new_dict(
"values".to_string(),
DataType::Dictionary(Box::new(DataType::Int32),
Box::new(DataType::Utf8)),
diff --git a/arrow-ipc/src/writer.rs b/arrow-ipc/src/writer.rs
index a9cc68bc13..6e32d0b157 100644
--- a/arrow-ipc/src/writer.rs
+++ b/arrow-ipc/src/writer.rs
@@ -483,7 +483,6 @@ impl IpcWriteOptions {
| crate::MetadataVersion::V3 =>
Err(ArrowError::InvalidArgumentError(
"Writing IPC metadata version 3 and lower not
supported".to_string(),
)),
- #[allow(deprecated)]
crate::MetadataVersion::V4 => Ok(Self {
alignment,
write_legacy_ipc_format,
@@ -762,7 +761,7 @@ impl IpcDataGenerator {
Ok(())
}
- #[allow(clippy::too_many_arguments)]
+ #[expect(clippy::too_many_arguments)]
fn encode_dictionaries<I: Iterator<Item = i64>>(
&self,
field: &Field,
@@ -1373,7 +1372,6 @@ impl DictionaryTracker {
/// is true, an error will be generated if an update to an
/// existing dictionary is attempted.
pub fn new(error_on_replacement: bool) -> Self {
- #[allow(deprecated)]
Self {
written: HashMap::new(),
dict_ids: Vec::new(),
@@ -3209,7 +3207,7 @@ mod tests {
let array = Arc::new(inner) as ArrayRef;
// Dict field with id 2
- #[allow(deprecated)]
+ #[expect(deprecated)]
let dctfield = Field::new_dict("dict", array.data_type().clone(),
false, 0, false);
let union_fields = [(0, Arc::new(dctfield))].into_iter().collect();
@@ -3255,7 +3253,7 @@ mod tests {
let array = Arc::new(inner) as ArrayRef;
// Dict field with id 2
- #[allow(deprecated)]
+ #[expect(deprecated)]
let dctfield = Arc::new(Field::new_dict(
"dict",
array.data_type().clone(),
@@ -4285,7 +4283,7 @@ mod tests {
#[test]
fn test_roundtrip_list_view_of_dict() {
- #[allow(deprecated)]
+ #[expect(deprecated)]
let list_data_type = DataType::ListView(Arc::new(Field::new_dict(
"item",
DataType::Dictionary(Box::new(DataType::Int32),
Box::new(DataType::Utf8)),
@@ -4300,7 +4298,7 @@ mod tests {
#[test]
fn test_roundtrip_large_list_view_of_dict() {
- #[allow(deprecated)]
+ #[expect(deprecated)]
let list_data_type = DataType::LargeListView(Arc::new(Field::new_dict(
"item",
DataType::Dictionary(Box::new(DataType::Int32),
Box::new(DataType::Utf8)),
@@ -4315,7 +4313,7 @@ mod tests {
#[test]
fn test_roundtrip_sliced_list_view_of_dict() {
- #[allow(deprecated)]
+ #[expect(deprecated)]
let list_data_type = DataType::ListView(Arc::new(Field::new_dict(
"item",
DataType::Dictionary(Box::new(DataType::Int32),
Box::new(DataType::Utf8)),
@@ -4365,7 +4363,7 @@ mod tests {
let keys = Int32Array::from_iter_values([0, 0, 1, 2, 3, 0, 2]);
let dict_array = DictionaryArray::new(keys, Arc::new(values));
- #[allow(deprecated)]
+ #[expect(deprecated)]
let dict_field = Arc::new(Field::new_dict(
"dict",
DataType::Dictionary(Box::new(DataType::Int32),
Box::new(DataType::Utf8)),
@@ -4409,7 +4407,7 @@ mod tests {
let keys = Int32Array::from_iter_values([0, 0, 1, 2, 3, 0, 2]);
let dict_array = DictionaryArray::new(keys, Arc::new(values));
- #[allow(deprecated)]
+ #[expect(deprecated)]
let dict_field = Arc::new(Field::new_dict(
"dict",
DataType::Dictionary(Box::new(DataType::Int32),
Box::new(DataType::Utf8)),
@@ -4456,7 +4454,7 @@ mod tests {
let values = Int32Array::from(vec![1, 2, 3, 4, 5, 6]);
- #[allow(deprecated)]
+ #[expect(deprecated)]
let entries_field = Arc::new(Field::new(
Field::MAP_ENTRIES_FIELD_DEFAULT_NAME,
DataType::Struct(
@@ -4528,7 +4526,7 @@ mod tests {
let value_keys = Int32Array::from_iter_values([0, 1, 2, 0, 1, 0]);
let dict_values = DictionaryArray::new(value_keys,
Arc::new(value_values));
- #[allow(deprecated)]
+ #[expect(deprecated)]
let entries_field = Arc::new(Field::new(
Field::MAP_ENTRIES_FIELD_DEFAULT_NAME,
DataType::Struct(