fix: clippy io_other_error

This commit is contained in:
Christian Haynes 2025-07-23 13:02:43 -04:00
parent 4b9fc3b5b7
commit a9f037bd40
No known key found for this signature in database
2 changed files with 6 additions and 8 deletions

View File

@ -491,20 +491,18 @@ fn make_mmap(tmpfile: &mut NamedTempFile, size: Option<usize>) -> Result<Option<
#[cfg(feature = "mmap")]
#[cfg(target_os = "linux")]
fn allocate_file(file: &std::fs::File, size: usize) -> std::io::Result<()> {
use std::io::{Error, ErrorKind};
use std::io::Error;
use std::os::fd::AsRawFd;
let fd = file.as_raw_fd();
match unsafe { libc::posix_fallocate64(fd, 0, size as i64) } {
0 => Ok(()),
libc::ENOSPC => Err(Error::new(
ErrorKind::Other, // ErrorKind::StorageFull is unstable
libc::ENOSPC => Err(Error::other(
"cannot allocate file: no space left on device",
)),
err => Err(Error::new(
ErrorKind::Other,
format!("posix_fallocate64 failed with code {err}"),
)),
err => Err(Error::other(format!(
"posix_fallocate64 failed with code {err}"
))),
}
}

View File

@ -59,5 +59,5 @@ impl<T> IoErrorExt<T> for std::result::Result<T, serde_json::Error> {
}
pub fn io_error(err: impl Into<Box<dyn std::error::Error + Send + Sync>>) -> std::io::Error {
std::io::Error::new(std::io::ErrorKind::Other, err)
std::io::Error::other(err)
}