diff --git a/dev/mvn-build-helper/build-native.sh b/dev/mvn-build-helper/build-native.sh index 8cc62ad78..548ab9a91 100755 --- a/dev/mvn-build-helper/build-native.sh +++ b/dev/mvn-build-helper/build-native.sh @@ -94,8 +94,7 @@ if [ ! -f "$cache_libpath" ] || [ "$new_checksum" != "$old_checksum" ]; then cargo fmt --all -q -- 2>&1 echo "Running cargo clippy..." - # First eliminate unwrap; then enable -D warnings to enforce all default lints. - cargo clippy --all-targets --workspace -- -A warnings -A clippy::all -D clippy::unwrap_used 2>&1 + cargo clippy --all-targets --workspace -- -D warnings 2>&1 echo "Building native with [$profile] profile..." cargo build --profile="$profile" $features_arg --verbose --locked --frozen 2>&1 diff --git a/native-engine/auron-jni-bridge/src/jni_bridge.rs b/native-engine/auron-jni-bridge/src/jni_bridge.rs index 55d6c2b2e..46009fbd3 100644 --- a/native-engine/auron-jni-bridge/src/jni_bridge.rs +++ b/native-engine/auron-jni-bridge/src/jni_bridge.rs @@ -471,7 +471,7 @@ impl JavaClasses<'static> { pub fn init(env: &JNIEnv) { if let Err(err) = JNI_JAVA_CLASSES.get_or_try_init(|| -> Result<_, Box> { log::info!("Initializing JavaClasses..."); - let env = unsafe { std::mem::transmute::<_, &'static JNIEnv>(env) }; + let env = unsafe { std::mem::transmute::<&JNIEnv, &'static JNIEnv>(env) }; let jni_bridge = JniBridge::new(env)?; let classloader = env .call_static_method_unchecked( @@ -1677,7 +1677,7 @@ fn get_global_ref_jobject<'a>(env: &JNIEnv<'a>, obj: JObject<'a>) -> JniResult>(global.as_obj()) }; + let global_obj = unsafe { std::mem::transmute::>(global.as_obj()) }; let _ = std::mem::ManuallyDrop::new(global); Ok(global_obj) } diff --git a/native-engine/auron-planner/build.rs b/native-engine/auron-planner/build.rs index afcf85157..8c1e66202 100644 --- a/native-engine/auron-planner/build.rs +++ b/native-engine/auron-planner/build.rs @@ -40,10 +40,10 @@ fn main() -> Result<(), String> { } } if let Some(path) = protoc_file { - eprintln!("Using protoc executable: {:?}", path); + eprintln!("Using protoc executable: {path:?}"); prost_build.protoc_executable(path); } prost_build .compile_protos(&["proto/auron.proto"], &["proto"]) - .map_err(|e| format!("protobuf compilation failed: {}", e)) + .map_err(|e| format!("protobuf compilation failed: {e}")) } diff --git a/native-engine/datafusion-ext-commons/src/arrow/eq_comparator.rs b/native-engine/datafusion-ext-commons/src/arrow/eq_comparator.rs index 1cccb9e7c..358df7e00 100644 --- a/native-engine/datafusion-ext-commons/src/arrow/eq_comparator.rs +++ b/native-engine/datafusion-ext-commons/src/arrow/eq_comparator.rs @@ -744,10 +744,10 @@ pub mod tests { #[test] fn test_bytes() { - test_bytes_impl::(); - test_bytes_impl::(); - test_bytes_impl::(); - test_bytes_impl::(); + let _ = test_bytes_impl::(); + let _ = test_bytes_impl::(); + let _ = test_bytes_impl::(); + let _ = test_bytes_impl::(); } #[test] diff --git a/native-engine/datafusion-ext-commons/src/io/batch_serde.rs b/native-engine/datafusion-ext-commons/src/io/batch_serde.rs index bbed9b365..3ab6c6e6f 100644 --- a/native-engine/datafusion-ext-commons/src/io/batch_serde.rs +++ b/native-engine/datafusion-ext-commons/src/io/batch_serde.rs @@ -741,7 +741,7 @@ mod test { ])?; assert_batches_eq!( - vec![ + [ "+-----------+-----------+", "| list1 | list2 |", "+-----------+-----------+", @@ -761,7 +761,7 @@ mod test { let (decoded_num_rows, decoded_cols) = read_batch(&mut cursor, &batch.schema())?.expect("non-empty batch"); assert_batches_eq!( - vec![ + [ "+-----------+-----------+", "| list1 | list2 |", "+-----------+-----------+", @@ -786,7 +786,7 @@ mod test { let (decoded_num_rows, decoded_cols) = read_batch(&mut cursor, &batch.schema())?.expect("non-empty batch"); assert_batches_eq!( - vec![ + [ "+----------+----------+", "| list1 | list2 |", "+----------+----------+", diff --git a/native-engine/datafusion-ext-commons/src/io/ipc_compression.rs b/native-engine/datafusion-ext-commons/src/io/ipc_compression.rs index cb2e51e6c..c774c7453 100644 --- a/native-engine/datafusion-ext-commons/src/io/ipc_compression.rs +++ b/native-engine/datafusion-ext-commons/src/io/ipc_compression.rs @@ -272,7 +272,7 @@ fn io_compression_codec() -> &'static str { if is_jni_bridge_inited() { conf::SPARK_IO_COMPRESSION_CODEC.value() } else { - Ok(format!("lz4")) // for testing + Ok("lz4".to_string()) // for testing } }) .expect("error reading spark.io.compression.codec") diff --git a/native-engine/datafusion-ext-commons/src/spark_hash.rs b/native-engine/datafusion-ext-commons/src/spark_hash.rs index 66be98486..6dc9c0b8a 100644 --- a/native-engine/datafusion-ext-commons/src/spark_hash.rs +++ b/native-engine/datafusion-ext-commons/src/spark_hash.rs @@ -523,7 +523,7 @@ mod tests { let value_data = ArrayData::builder(DataType::Int32) .len(6) .add_buffer(Buffer::from_slice_ref( - &[1i32, 2, 3, 4, 5, 6].to_byte_slice(), + [1i32, 2, 3, 4, 5, 6].to_byte_slice(), )) .build()?; @@ -531,7 +531,7 @@ mod tests { let list_data_type = DataType::new_list(DataType::Int32, false); let list_data = ArrayData::builder(list_data_type) .len(3) - .add_buffer(Buffer::from_slice_ref(&[0i32, 2, 5, 6].to_byte_slice())) + .add_buffer(Buffer::from_slice_ref([0i32, 2, 5, 6].to_byte_slice())) .add_child_data(value_data) .build()?; @@ -550,20 +550,20 @@ mod tests { let key_data = ArrayData::builder(DataType::Int32) .len(8) .add_buffer(Buffer::from_slice_ref( - &[0, 1, 2, 3, 4, 5, 6, 7].to_byte_slice(), + [0, 1, 2, 3, 4, 5, 6, 7].to_byte_slice(), )) .build()?; let value_data = ArrayData::builder(DataType::UInt32) .len(8) .add_buffer(Buffer::from_slice_ref( - &[0u32, 10, 20, 0, 40, 0, 60, 70].to_byte_slice(), + [0u32, 10, 20, 0, 40, 0, 60, 70].to_byte_slice(), )) .null_bit_buffer(Some(Buffer::from(&[0b11010110]))) .build()?; // Construct a buffer for value offsets, for the nested array: // [[0, 1, 2], [3, 4, 5], [6, 7]] - let entry_offsets = Buffer::from_slice_ref(&[0, 3, 6, 8].to_byte_slice()); + let entry_offsets = Buffer::from_slice_ref([0, 3, 6, 8].to_byte_slice()); let keys_field = Arc::new(Field::new("keys", DataType::Int32, false)); let values_field = Arc::new(Field::new("values", DataType::UInt32, true));