Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
20 changes: 4 additions & 16 deletions src/io/snappy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ impl<W: Write> SnapCountWriter<W> {
.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())?;

Expand Down Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions src/upload/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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");
Expand Down