From 7b6e35b992e96581ed5feee917fdb3c2d5918839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Fri, 17 May 2024 15:34:04 +0200 Subject: [PATCH 1/4] use core::fmt instead of std::fmt --- build/probe.rs | 2 +- src/display.rs | 2 +- src/lib.rs | 4 ++-- tests/test_display.rs | 2 +- tests/test_error.rs | 2 +- tests/test_expr.rs | 2 +- tests/test_generics.rs | 2 +- tests/test_path.rs | 2 +- tests/ui/fallback-impl-with-display.rs | 2 +- tests/ui/lifetime.rs | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/build/probe.rs b/build/probe.rs index 0dce6f5b..28437870 100644 --- a/build/probe.rs +++ b/build/probe.rs @@ -5,7 +5,7 @@ #![feature(error_generic_member_access)] use std::error::{Error, Request}; -use std::fmt::{self, Debug, Display}; +use core::fmt::{self, Debug, Display}; struct MyError(Thing); struct Thing; diff --git a/src/display.rs b/src/display.rs index 27098f16..3c43216a 100644 --- a/src/display.rs +++ b/src/display.rs @@ -1,4 +1,4 @@ -use std::fmt::Display; +use core::fmt::Display; use std::path::{self, Path, PathBuf}; #[doc(hidden)] diff --git a/src/lib.rs b/src/lib.rs index 81a04b07..9b9c5af6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,7 +62,7 @@ //! which may be arbitrary expressions. For example: //! //! ```rust -//! # use std::i32; +//! # use core::i32; //! # use thiserror::Error; //! # //! #[derive(Error, Debug)] @@ -129,7 +129,7 @@ //! std::error::Error` will work as a source. //! //! ```rust -//! # use std::fmt::{self, Display}; +//! # use core::fmt::{self, Display}; //! # use thiserror::Error; //! # //! #[derive(Error, Debug)] diff --git a/tests/test_display.rs b/tests/test_display.rs index 95a210f0..c05d157a 100644 --- a/tests/test_display.rs +++ b/tests/test_display.rs @@ -1,6 +1,6 @@ #![allow(clippy::needless_raw_string_hashes, clippy::uninlined_format_args)] -use std::fmt::{self, Display}; +use core::fmt::{self, Display}; use thiserror::Error; fn assert(expected: &str, value: T) { diff --git a/tests/test_error.rs b/tests/test_error.rs index fab934d7..eb52cefb 100644 --- a/tests/test_error.rs +++ b/tests/test_error.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] -use std::fmt::{self, Display}; +use core::fmt::{self, Display}; use std::io; use thiserror::Error; diff --git a/tests/test_expr.rs b/tests/test_expr.rs index 028f34ee..c5e3b4b1 100644 --- a/tests/test_expr.rs +++ b/tests/test_expr.rs @@ -1,6 +1,6 @@ #![allow(clippy::iter_cloned_collect, clippy::uninlined_format_args)] -use std::fmt::Display; +use core::fmt::Display; use thiserror::Error; // Some of the elaborate cases from the rcc codebase, which is a C compiler in diff --git a/tests/test_generics.rs b/tests/test_generics.rs index c94d95ef..ac5d6f3b 100644 --- a/tests/test_generics.rs +++ b/tests/test_generics.rs @@ -1,6 +1,6 @@ #![allow(clippy::needless_late_init, clippy::uninlined_format_args)] -use std::fmt::{self, Debug, Display}; +use core::fmt::{self, Debug, Display}; use thiserror::Error; pub struct NoFormat; diff --git a/tests/test_path.rs b/tests/test_path.rs index a34a3d74..f0540779 100644 --- a/tests/test_path.rs +++ b/tests/test_path.rs @@ -1,5 +1,5 @@ +use core::fmt::Display; use ref_cast::RefCast; -use std::fmt::Display; use std::path::{Path, PathBuf}; use thiserror::Error; diff --git a/tests/ui/fallback-impl-with-display.rs b/tests/ui/fallback-impl-with-display.rs index 33411873..23dcf287 100644 --- a/tests/ui/fallback-impl-with-display.rs +++ b/tests/ui/fallback-impl-with-display.rs @@ -1,4 +1,4 @@ -use std::fmt::{self, Display}; +use core::fmt::{self, Display}; use thiserror::Error; #[derive(Error, Debug)] diff --git a/tests/ui/lifetime.rs b/tests/ui/lifetime.rs index 698f8c4e..a82909d6 100644 --- a/tests/ui/lifetime.rs +++ b/tests/ui/lifetime.rs @@ -1,4 +1,4 @@ -use std::fmt::Debug; +use core::fmt::Debug; use thiserror::Error; #[derive(Error, Debug)] From ce974bc2bd7773ef6e2cf19a2e35c0d31519c353 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Fri, 17 May 2024 15:42:03 +0200 Subject: [PATCH 2/4] also {std -> core}::panic::UnwindSafe --- src/aserror.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aserror.rs b/src/aserror.rs index 54fc6f11..4cd0fec6 100644 --- a/src/aserror.rs +++ b/src/aserror.rs @@ -1,5 +1,5 @@ use std::error::Error; -use std::panic::UnwindSafe; +use core::panic::UnwindSafe; #[doc(hidden)] pub trait AsDynError<'a>: Sealed { From e3b1b91ced4e590ac8823fa0945f01a0560dada9 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 17 May 2024 09:43:23 -0700 Subject: [PATCH 3/4] Format PR 299 with rustfmt --- build/probe.rs | 2 +- src/aserror.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/probe.rs b/build/probe.rs index 28437870..faf25c5c 100644 --- a/build/probe.rs +++ b/build/probe.rs @@ -4,8 +4,8 @@ #![feature(error_generic_member_access)] -use std::error::{Error, Request}; use core::fmt::{self, Debug, Display}; +use std::error::{Error, Request}; struct MyError(Thing); struct Thing; diff --git a/src/aserror.rs b/src/aserror.rs index 4cd0fec6..11cb4d99 100644 --- a/src/aserror.rs +++ b/src/aserror.rs @@ -1,5 +1,5 @@ -use std::error::Error; use core::panic::UnwindSafe; +use std::error::Error; #[doc(hidden)] pub trait AsDynError<'a>: Sealed { From 5c8016393fec09330ae495d71edee4d8104a9466 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 17 May 2024 09:44:33 -0700 Subject: [PATCH 4/4] Release 1.0.61 --- Cargo.toml | 4 ++-- impl/Cargo.toml | 2 +- src/lib.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fd2d13d1..72554792 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thiserror" -version = "1.0.60" +version = "1.0.61" authors = ["David Tolnay "] categories = ["rust-patterns"] description = "derive(Error)" @@ -12,7 +12,7 @@ repository = "https://github.com/dtolnay/thiserror" rust-version = "1.56" [dependencies] -thiserror-impl = { version = "=1.0.60", path = "impl" } +thiserror-impl = { version = "=1.0.61", path = "impl" } [dev-dependencies] anyhow = "1.0.73" diff --git a/impl/Cargo.toml b/impl/Cargo.toml index 698f9671..43b900b5 100644 --- a/impl/Cargo.toml +++ b/impl/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thiserror-impl" -version = "1.0.60" +version = "1.0.61" authors = ["David Tolnay "] description = "Implementation detail of the `thiserror` crate" edition = "2021" diff --git a/src/lib.rs b/src/lib.rs index 9b9c5af6..13c2b504 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -228,7 +228,7 @@ //! //! [`anyhow`]: https://github.com/dtolnay/anyhow -#![doc(html_root_url = "https://docs.rs/thiserror/1.0.60")] +#![doc(html_root_url = "https://docs.rs/thiserror/1.0.61")] #![allow( clippy::module_name_repetitions, clippy::needless_lifetimes,