diff options
author | Chih-Hung Hsieh <chh@google.com> | 2020-10-28 13:48:05 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-10-28 13:48:05 +0000 |
commit | 1c9569e5711e204498e57ddc4576ffc3efc2c0c1 (patch) | |
tree | 8edd33862debc1f7325810d7fae6adc564860285 | |
parent | ae90b2902831c6b619ee75e6567c962a2ee57eeb (diff) | |
parent | 468a2633d1cbafd5d20ff551c39a4589acd476f0 (diff) | |
download | thiserror-1c9569e5711e204498e57ddc4576ffc3efc2c0c1.tar.gz |
Upgrade rust/crates/thiserror to 1.0.21 am: 5cf648bae0 am: 08318c0434 am: 468a2633d1
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/thiserror/+/1474996
Change-Id: I978bef1eefe4b3083780b70f4c4dde11b87fef7a
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 10 | ||||
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | Cargo.toml.orig | 4 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rw-r--r-- | tests/test_backtrace.rs | 213 | ||||
-rw-r--r-- | tests/test_expr.rs | 1 | ||||
-rw-r--r-- | tests/ui/missing-display.rs | 9 | ||||
-rw-r--r-- | tests/ui/missing-display.stderr | 8 | ||||
-rw-r--r-- | tests/ui/no-display.rs | 6 | ||||
-rw-r--r-- | tests/ui/no-display.stderr | 21 | ||||
-rw-r--r-- | tests/ui/source-enum-not-error.rs | 5 | ||||
-rw-r--r-- | tests/ui/source-enum-not-error.stderr | 32 | ||||
-rw-r--r-- | tests/ui/source-struct-not-error.rs | 5 | ||||
-rw-r--r-- | tests/ui/source-struct-not-error.stderr | 29 |
15 files changed, 284 insertions, 73 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 16e6ee7..a0bee43 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "42b537acf08de385dcf6138f24e3274ff8a18148" + "sha1": "f757a0489b2cddfea15ab870b49f159ce1aa71cd" } } @@ -6,14 +6,12 @@ rust_library { crate_name: "thiserror", srcs: ["src/lib.rs"], edition: "2018", - proc_macros: [ - "libthiserror_impl", - ], + proc_macros: ["libthiserror_impl"], } // dependent_library ["feature_list"] -// proc-macro2-1.0.18 "default,proc-macro" +// proc-macro2-1.0.24 "default,proc-macro" // quote-1.0.7 "default,proc-macro" -// syn-1.0.34 "clone-impls,default,derive,full,parsing,printing,proc-macro,quote,visit" -// thiserror-impl-1.0.16 +// syn-1.0.48 "clone-impls,default,derive,parsing,printing,proc-macro,quote,visit" +// thiserror-impl-1.0.21 // unicode-xid-0.2.1 "default" @@ -13,7 +13,7 @@ [package] edition = "2018" name = "thiserror" -version = "1.0.20" +version = "1.0.21" authors = ["David Tolnay <dtolnay@gmail.com>"] description = "derive(Error)" documentation = "https://docs.rs/thiserror" @@ -24,7 +24,7 @@ repository = "https://github.com/dtolnay/thiserror" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] [dependencies.thiserror-impl] -version = "=1.0.20" +version = "=1.0.21" [dev-dependencies.anyhow] version = "1.0" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index a0308d8..ff7294d 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "thiserror" -version = "1.0.20" +version = "1.0.21" authors = ["David Tolnay <dtolnay@gmail.com>"] edition = "2018" license = "MIT OR Apache-2.0" @@ -11,7 +11,7 @@ categories = ["rust-patterns"] readme = "README.md" [dependencies] -thiserror-impl = { version = "=1.0.20", path = "impl" } +thiserror-impl = { version = "=1.0.21", path = "impl" } [dev-dependencies] anyhow = "1.0" @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/thiserror/thiserror-1.0.20.crate" + value: "https://static.crates.io/crates/thiserror/thiserror-1.0.21.crate" } - version: "1.0.20" + version: "1.0.21" license_type: NOTICE last_upgrade_date { year: 2020 - month: 8 - day: 27 + month: 10 + day: 26 } } diff --git a/tests/test_backtrace.rs b/tests/test_backtrace.rs new file mode 100644 index 0000000..09bc13d --- /dev/null +++ b/tests/test_backtrace.rs @@ -0,0 +1,213 @@ +#![cfg_attr(thiserror_nightly_testing, feature(backtrace))] + +use thiserror::Error; + +#[derive(Error, Debug)] +#[error("...")] +pub struct Inner; + +#[cfg(thiserror_nightly_testing)] +pub mod structs { + use super::Inner; + use std::backtrace::Backtrace; + use std::error::Error; + use std::sync::Arc; + use thiserror::Error; + + #[derive(Error, Debug)] + #[error("...")] + pub struct PlainBacktrace { + backtrace: Backtrace, + } + + #[derive(Error, Debug)] + #[error("...")] + pub struct ExplicitBacktrace { + #[backtrace] + backtrace: Backtrace, + } + + #[derive(Error, Debug)] + #[error("...")] + pub struct OptBacktrace { + #[backtrace] + backtrace: Option<Backtrace>, + } + + #[derive(Error, Debug)] + #[error("...")] + pub struct ArcBacktrace { + #[backtrace] + backtrace: Arc<Backtrace>, + } + + #[derive(Error, Debug)] + #[error("...")] + pub struct BacktraceFrom { + #[from] + source: Inner, + #[backtrace] + backtrace: Backtrace, + } + + #[derive(Error, Debug)] + #[error("...")] + pub struct OptBacktraceFrom { + #[from] + source: Inner, + #[backtrace] + backtrace: Option<Backtrace>, + } + + #[derive(Error, Debug)] + #[error("...")] + pub struct ArcBacktraceFrom { + #[from] + source: Inner, + #[backtrace] + backtrace: Arc<Backtrace>, + } + + #[test] + fn test_backtrace() { + let error = PlainBacktrace { + backtrace: Backtrace::capture(), + }; + assert!(error.backtrace().is_some()); + + let error = ExplicitBacktrace { + backtrace: Backtrace::capture(), + }; + assert!(error.backtrace().is_some()); + + let error = OptBacktrace { + backtrace: Some(Backtrace::capture()), + }; + assert!(error.backtrace().is_some()); + + let error = ArcBacktrace { + backtrace: Arc::new(Backtrace::capture()), + }; + assert!(error.backtrace().is_some()); + + let error = BacktraceFrom::from(Inner); + assert!(error.backtrace().is_some()); + + let error = OptBacktraceFrom::from(Inner); + assert!(error.backtrace().is_some()); + + let error = ArcBacktraceFrom::from(Inner); + assert!(error.backtrace().is_some()); + } +} + +#[cfg(thiserror_nightly_testing)] +pub mod enums { + use super::Inner; + use std::backtrace::Backtrace; + use std::error::Error; + use std::sync::Arc; + use thiserror::Error; + + #[derive(Error, Debug)] + pub enum PlainBacktrace { + #[error("...")] + Test { backtrace: Backtrace }, + } + + #[derive(Error, Debug)] + pub enum ExplicitBacktrace { + #[error("...")] + Test { + #[backtrace] + backtrace: Backtrace, + }, + } + + #[derive(Error, Debug)] + pub enum OptBacktrace { + #[error("...")] + Test { + #[backtrace] + backtrace: Option<Backtrace>, + }, + } + + #[derive(Error, Debug)] + pub enum ArcBacktrace { + #[error("...")] + Test { + #[backtrace] + backtrace: Arc<Backtrace>, + }, + } + + #[derive(Error, Debug)] + pub enum BacktraceFrom { + #[error("...")] + Test { + #[from] + source: Inner, + #[backtrace] + backtrace: Backtrace, + }, + } + + #[derive(Error, Debug)] + pub enum OptBacktraceFrom { + #[error("...")] + Test { + #[from] + source: Inner, + #[backtrace] + backtrace: Option<Backtrace>, + }, + } + + #[derive(Error, Debug)] + pub enum ArcBacktraceFrom { + #[error("...")] + Test { + #[from] + source: Inner, + #[backtrace] + backtrace: Arc<Backtrace>, + }, + } + + #[test] + fn test_backtrace() { + let error = PlainBacktrace::Test { + backtrace: Backtrace::capture(), + }; + assert!(error.backtrace().is_some()); + + let error = ExplicitBacktrace::Test { + backtrace: Backtrace::capture(), + }; + assert!(error.backtrace().is_some()); + + let error = OptBacktrace::Test { + backtrace: Some(Backtrace::capture()), + }; + assert!(error.backtrace().is_some()); + + let error = ArcBacktrace::Test { + backtrace: Arc::new(Backtrace::capture()), + }; + assert!(error.backtrace().is_some()); + + let error = BacktraceFrom::from(Inner); + assert!(error.backtrace().is_some()); + + let error = OptBacktraceFrom::from(Inner); + assert!(error.backtrace().is_some()); + + let error = ArcBacktraceFrom::from(Inner); + assert!(error.backtrace().is_some()); + } +} + +#[test] +#[cfg_attr(not(thiserror_nightly_testing), ignore)] +fn test_backtrace() {} diff --git a/tests/test_expr.rs b/tests/test_expr.rs index add5811..87a56cf 100644 --- a/tests/test_expr.rs +++ b/tests/test_expr.rs @@ -1,4 +1,5 @@ #![deny(clippy::all, clippy::pedantic)] +#![allow(clippy::option_if_let_else)] use std::fmt::Display; use thiserror::Error; diff --git a/tests/ui/missing-display.rs b/tests/ui/missing-display.rs deleted file mode 100644 index 31e23fe..0000000 --- a/tests/ui/missing-display.rs +++ /dev/null @@ -1,9 +0,0 @@ -use thiserror::Error; - -#[derive(Error, Debug)] -pub enum MyError { - First, - Second, -} - -fn main() {} diff --git a/tests/ui/missing-display.stderr b/tests/ui/missing-display.stderr deleted file mode 100644 index 2dfec2a..0000000 --- a/tests/ui/missing-display.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0277]: `MyError` doesn't implement `std::fmt::Display` - --> $DIR/missing-display.rs:4:1 - | -4 | pub enum MyError { - | ^^^^^^^^^^^^^^^^ `MyError` cannot be formatted with the default formatter - | - = help: the trait `std::fmt::Display` is not implemented for `MyError` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead diff --git a/tests/ui/no-display.rs b/tests/ui/no-display.rs index 7a5b2a0..181a66e 100644 --- a/tests/ui/no-display.rs +++ b/tests/ui/no-display.rs @@ -1,10 +1,12 @@ -use std::thread::Thread; use thiserror::Error; +#[derive(Debug)] +struct NoDisplay; + #[derive(Error, Debug)] #[error("thread: {thread}")] pub struct Error { - thread: Thread, + thread: NoDisplay, } fn main() {} diff --git a/tests/ui/no-display.stderr b/tests/ui/no-display.stderr index 6a59def..b1a0c49 100644 --- a/tests/ui/no-display.stderr +++ b/tests/ui/no-display.stderr @@ -1,9 +1,12 @@ -error[E0599]: no method named `as_display` found for reference `&std::thread::Thread` in the current scope - --> $DIR/no-display.rs:5:9 - | -5 | #[error("thread: {thread}")] - | ^^^^^^^^^^^^^^^^^^ method not found in `&std::thread::Thread` - | - = note: the method `as_display` exists but the following trait bounds were not satisfied: - `std::thread::Thread: std::fmt::Display` - which is required by `&std::thread::Thread: thiserror::display::DisplayAsDisplay` +error[E0599]: no method named `as_display` found for reference `&NoDisplay` in the current scope + --> $DIR/no-display.rs:7:9 + | +4 | struct NoDisplay; + | ----------------- doesn't satisfy `NoDisplay: std::fmt::Display` +... +7 | #[error("thread: {thread}")] + | ^^^^^^^^^^^^^^^^^^ method not found in `&NoDisplay` + | + = note: the method `as_display` exists but the following trait bounds were not satisfied: + `NoDisplay: std::fmt::Display` + which is required by `&NoDisplay: DisplayAsDisplay` diff --git a/tests/ui/source-enum-not-error.rs b/tests/ui/source-enum-not-error.rs index 5840d7d..3eb0d3e 100644 --- a/tests/ui/source-enum-not-error.rs +++ b/tests/ui/source-enum-not-error.rs @@ -1,10 +1,13 @@ use thiserror::Error; +#[derive(Debug)] +pub struct NotError; + #[derive(Error, Debug)] #[error("...")] pub enum ErrorEnum { Broken { - source: String, + source: NotError, }, } diff --git a/tests/ui/source-enum-not-error.stderr b/tests/ui/source-enum-not-error.stderr index 39e96f8..3dee730 100644 --- a/tests/ui/source-enum-not-error.stderr +++ b/tests/ui/source-enum-not-error.stderr @@ -1,15 +1,17 @@ -error[E0599]: no method named `as_dyn_error` found for reference `&std::string::String` in the current scope - --> $DIR/source-enum-not-error.rs:7:9 - | -7 | source: String, - | ^^^^^^ method not found in `&std::string::String` - | - = note: the method `as_dyn_error` exists but the following trait bounds were not satisfied: - `std::string::String: std::error::Error` - which is required by `std::string::String: thiserror::aserror::AsDynError` - `&std::string::String: std::error::Error` - which is required by `&std::string::String: thiserror::aserror::AsDynError` - `str: std::marker::Sized` - which is required by `str: thiserror::aserror::AsDynError` - `str: std::error::Error` - which is required by `str: thiserror::aserror::AsDynError` +error[E0599]: no method named `as_dyn_error` found for reference `&NotError` in the current scope + --> $DIR/source-enum-not-error.rs:10:9 + | +4 | pub struct NotError; + | -------------------- + | | + | doesn't satisfy `NotError: AsDynError` + | doesn't satisfy `NotError: std::error::Error` +... +10 | source: NotError, + | ^^^^^^ method not found in `&NotError` + | + = note: the method `as_dyn_error` exists but the following trait bounds were not satisfied: + `NotError: std::error::Error` + which is required by `NotError: AsDynError` + `&NotError: std::error::Error` + which is required by `&NotError: AsDynError` diff --git a/tests/ui/source-struct-not-error.rs b/tests/ui/source-struct-not-error.rs index e907e97..d59df1e 100644 --- a/tests/ui/source-struct-not-error.rs +++ b/tests/ui/source-struct-not-error.rs @@ -1,9 +1,12 @@ use thiserror::Error; +#[derive(Debug)] +struct NotError; + #[derive(Error, Debug)] #[error("...")] pub struct ErrorStruct { - source: String, + source: NotError, } fn main() {} diff --git a/tests/ui/source-struct-not-error.stderr b/tests/ui/source-struct-not-error.stderr index d8cf2b1..0aa03dd 100644 --- a/tests/ui/source-struct-not-error.stderr +++ b/tests/ui/source-struct-not-error.stderr @@ -1,13 +1,16 @@ -error[E0599]: no method named `as_dyn_error` found for struct `std::string::String` in the current scope - --> $DIR/source-struct-not-error.rs:6:5 - | -6 | source: String, - | ^^^^^^ method not found in `std::string::String` - | - = note: the method `as_dyn_error` exists but the following trait bounds were not satisfied: - `std::string::String: std::error::Error` - which is required by `std::string::String: thiserror::aserror::AsDynError` - `str: std::marker::Sized` - which is required by `str: thiserror::aserror::AsDynError` - `str: std::error::Error` - which is required by `str: thiserror::aserror::AsDynError` +error[E0599]: no method named `as_dyn_error` found for struct `NotError` in the current scope + --> $DIR/source-struct-not-error.rs:9:5 + | +4 | struct NotError; + | ---------------- + | | + | method `as_dyn_error` not found for this + | doesn't satisfy `NotError: AsDynError` + | doesn't satisfy `NotError: std::error::Error` +... +9 | source: NotError, + | ^^^^^^ method not found in `NotError` + | + = note: the method `as_dyn_error` exists but the following trait bounds were not satisfied: + `NotError: std::error::Error` + which is required by `NotError: AsDynError` |