From 2d1c63f8974ecec8a71d981e615e771d6aedcb78 Mon Sep 17 00:00:00 2001 From: winlogon Date: Thu, 9 Oct 2025 16:09:49 +0200 Subject: [PATCH] chore(clippy-lint): use io::Error::other --- src/error.rs | 6 +++--- src/eyreish/into_diagnostic.rs | 4 ++-- tests/common/mod.rs | 2 +- tests/test_boxed.rs | 10 +++++----- tests/test_source.rs | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/error.rs b/src/error.rs index f77ce1e..643cf63 100644 --- a/src/error.rs +++ b/src/error.rs @@ -78,7 +78,7 @@ impl Diagnostic for MietteError { #[cfg(test)] pub(crate) mod tests { - use std::{error::Error, io::ErrorKind}; + use std::error::Error; use super::*; @@ -99,9 +99,9 @@ pub(crate) mod tests { #[test] fn io_error() { - let inner_error = io::Error::new(ErrorKind::Other, "halt and catch fire"); + let inner_error = io::Error::other("halt and catch fire"); let outer_error = TestError(inner_error); - let io_error = io::Error::new(ErrorKind::Other, outer_error); + let io_error = io::Error::other(outer_error); let miette_error = MietteError::from(io_error); diff --git a/src/eyreish/into_diagnostic.rs b/src/eyreish/into_diagnostic.rs index 1f90c34..f0a6351 100644 --- a/src/eyreish/into_diagnostic.rs +++ b/src/eyreish/into_diagnostic.rs @@ -46,7 +46,7 @@ impl IntoDiagnostic for R #[cfg(test)] mod tests { - use std::io::{self, ErrorKind}; + use std::io; use super::*; @@ -54,7 +54,7 @@ mod tests { #[test] fn diagnostic_error() { - let inner_error = io::Error::new(ErrorKind::Other, "halt and catch fire"); + let inner_error = io::Error::other("halt and catch fire"); let outer_error: Result<(), _> = Err(TestError(inner_error)); let diagnostic_error = outer_error.into_diagnostic().unwrap_err(); diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 223810c..8c48253 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -10,5 +10,5 @@ pub fn bail_fmt() -> Result<()> { } pub fn bail_error() -> Result<()> { - bail!(io::Error::new(io::ErrorKind::Other, "oh no!")); + bail!(io::Error::other("oh no!")); } diff --git a/tests/test_boxed.rs b/tests/test_boxed.rs index 9f9f4e2..db8d214 100644 --- a/tests/test_boxed.rs +++ b/tests/test_boxed.rs @@ -42,13 +42,13 @@ fn test_boxed_str_stderr() { #[test] fn test_boxed_thiserror() { let error = MyError { - source: io::Error::new(io::ErrorKind::Other, "oh no!"), + source: io::Error::other("oh no!"), }; let report: Report = miette!(error); assert_eq!("oh no!", report.source().unwrap().to_string()); let error = MyError { - source: io::Error::new(io::ErrorKind::Other, "oh no!!!!"), + source: io::Error::other("oh no!!!!"), }; let error: Box = Box::new(error); let report = Report::new_boxed(error); @@ -203,7 +203,7 @@ fn test_boxed_custom_diagnostic() { let related = CustomDiagnostic::new(); let main_diagnostic = CustomDiagnostic::new() - .with_source(io::Error::new(io::ErrorKind::Other, "oh no!")) + .with_source(io::Error::other("oh no!")) .with_related(related); let report = Report::new_boxed(Box::new(main_diagnostic)); @@ -211,7 +211,7 @@ fn test_boxed_custom_diagnostic() { let related = CustomDiagnostic::new(); let main_diagnostic = CustomDiagnostic::new() - .with_source(io::Error::new(io::ErrorKind::Other, "oh no!")) + .with_source(io::Error::other("oh no!")) .with_related(related); let main_diagnostic = Box::new(main_diagnostic) as Box; let report = miette!(main_diagnostic); @@ -228,7 +228,7 @@ fn test_boxed_custom_diagnostic() { #[test] fn test_boxed_sources() { let error = MyError { - source: io::Error::new(io::ErrorKind::Other, "oh no!"), + source: io::Error::other("oh no!"), }; let error = Box::::from(error); let error: Report = miette!(error).wrap_err("it failed"); diff --git a/tests/test_source.rs b/tests/test_source.rs index 9511bdb..303c2f9 100644 --- a/tests/test_source.rs +++ b/tests/test_source.rs @@ -50,7 +50,7 @@ fn test_fmt_source() { #[test] #[ignore = "Again with the io::Error source issue?"] fn test_io_source() { - let io = io::Error::new(io::ErrorKind::Other, "oh no!"); + let io = io::Error::other("oh no!"); let error: Report = miette!(TestError::Io(io)); assert_eq!("oh no!", error.source().unwrap().to_string()); }