From 393709f15f218ad91febb37d52c9a29229efb66c Mon Sep 17 00:00:00 2001 From: Brian Caswell Date: Thu, 16 Jul 2026 15:13:40 +0000 Subject: [PATCH] Allow stable std I/O APIs in Clippy --- Cargo.toml | 2 +- src/io/snappy.rs | 20 ++++---------------- src/upload/stream.rs | 5 ++--- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6c5adcfe..ef078764 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,7 +59,7 @@ panic = "deny" pattern_type_mismatch = "warn" redundant_pub_crate = "deny" shadow_unrelated = "deny" -std_instead_of_core = "deny" +std_instead_of_core = "allow" undocumented_unsafe_blocks = "deny" unused_trait_names = "warn" unwrap_used = "deny" diff --git a/src/io/snappy.rs b/src/io/snappy.rs index dd9bb64d..b8a25238 100644 --- a/src/io/snappy.rs +++ b/src/io/snappy.rs @@ -23,12 +23,8 @@ impl SnapCountWriter { .into_inner() .map_err(snap::write::IntoInnerError::into_error)?; - let count = u64::try_from(inner.count()).map_err(|_| { - std::io::Error::new( - std::io::ErrorKind::InvalidData, - "unable to convert compressed length to u64", - ) - })?; + let count = u64::try_from(inner.count()) + .map_err(|_| std::io::Error::other("unable to convert compressed length to u64"))?; let mut handle = inner.into_inner(); handle.write_all(&count.to_le_bytes())?; @@ -67,19 +63,11 @@ mod tests { let compressed_len = compressed_data.split_off(compressed_data.len() - 8); let compressed_len = u64::from_le_bytes(compressed_len.try_into().map_err(|_| { - std::io::Error::new( - std::io::ErrorKind::InvalidData, - "unable to convert compressed length to u64", - ) + std::io::Error::other("compressed length trailer must contain exactly 8 bytes") })?); assert_eq!( compressed_len, - u64::try_from(compressed_data.len()).map_err(|_| { - std::io::Error::new( - std::io::ErrorKind::InvalidData, - "unable to convert compressed length to u64", - ) - })? + u64::try_from(compressed_data.len()).map_err(std::io::Error::other)? ); assert_ne!(compressed_data, many_a); diff --git a/src/upload/stream.rs b/src/upload/stream.rs index c0f34095..c896c194 100644 --- a/src/upload/stream.rs +++ b/src/upload/stream.rs @@ -572,7 +572,7 @@ mod tests { }; use std::{ fs, - io::{Cursor, Read as _, Seek as _, SeekFrom}, + io::{Cursor, Read as _, Seek as _, SeekFrom, copy}, path::Path, sync::Mutex as StdMutex, }; @@ -848,8 +848,7 @@ mod tests { Format::AvmlCompressed => { let mut decoder = snap::read::FrameDecoder::new(&mut cursor) .take(u64::try_from(size).expect("positive header size fits u64")); - std::io::copy(&mut decoder, &mut std::io::sink()) - .expect("compressed payload decodes"); + copy(&mut decoder, &mut Vec::new()).expect("compressed payload decodes"); cursor .seek(SeekFrom::Current(8)) .expect("seek past compressed byte count");