From 933f15e068e3aaf37444484c2571f84aa799d221 Mon Sep 17 00:00:00 2001 From: Joel Galenson Date: Mon, 21 Jun 2021 14:13:07 -0700 Subject: Upgrade rust/crates/thiserror to 1.0.25 Test: make Change-Id: If65cc840f54901ed2874343075cf7cb2b40f4323 --- .cargo_vcs_info.json | 2 +- Android.bp | 8 ++++---- Cargo.toml | 4 ++-- Cargo.toml.orig | 4 ++-- METADATA | 8 ++++---- TEST_MAPPING | 31 +++++++++++++++++-------------- src/aserror.rs | 20 ++++++++++---------- tests/test_source.rs | 6 +++++- tests/test_transparent.rs | 21 +++++++++++++++++++++ tests/ui/concat-display.stderr | 2 +- 10 files changed, 67 insertions(+), 39 deletions(-) diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 349cbda..bc886ab 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "1b0a84996b9492c0dc5779127a91c930f23a259e" + "sha1": "19cb5cee4b51203f6801daa3ff0185761d0d3d4c" } } diff --git a/Android.bp b/Android.bp index b0525ae..9212d3b 100644 --- a/Android.bp +++ b/Android.bp @@ -51,8 +51,8 @@ rust_library { } // dependent_library ["feature_list"] -// proc-macro2-1.0.26 "default,proc-macro" +// proc-macro2-1.0.27 "default,proc-macro" // quote-1.0.9 "default,proc-macro" -// syn-1.0.71 "clone-impls,default,derive,parsing,printing,proc-macro,quote" -// thiserror-impl-1.0.24 -// unicode-xid-0.2.1 "default" +// syn-1.0.73 "clone-impls,default,derive,parsing,printing,proc-macro,quote" +// thiserror-impl-1.0.25 +// unicode-xid-0.2.2 "default" diff --git a/Cargo.toml b/Cargo.toml index e3ef65a..011dab7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ [package] edition = "2018" name = "thiserror" -version = "1.0.24" +version = "1.0.25" authors = ["David Tolnay "] 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.24" +version = "=1.0.25" [dev-dependencies.anyhow] version = "1.0" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 0517a91..136c938 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "thiserror" -version = "1.0.24" +version = "1.0.25" authors = ["David Tolnay "] edition = "2018" license = "MIT OR Apache-2.0" @@ -11,7 +11,7 @@ categories = ["rust-patterns"] readme = "README.md" [dependencies] -thiserror-impl = { version = "=1.0.24", path = "impl" } +thiserror-impl = { version = "=1.0.25", path = "impl" } [dev-dependencies] anyhow = "1.0" diff --git a/METADATA b/METADATA index 3b9f5d5..f99aa6d 100644 --- a/METADATA +++ b/METADATA @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/thiserror/thiserror-1.0.24.crate" + value: "https://static.crates.io/crates/thiserror/thiserror-1.0.25.crate" } - version: "1.0.24" + version: "1.0.25" license_type: NOTICE last_upgrade_date { year: 2021 - month: 2 - day: 18 + month: 6 + day: 21 } } diff --git a/TEST_MAPPING b/TEST_MAPPING index c21ac98..254a499 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -2,52 +2,55 @@ { "presubmit": [ { - "name": "anyhow_device_test_tests_test_repr" + "name": "anyhow_device_test_src_lib" }, { - "name": "keystore2_test" + "name": "anyhow_device_test_tests_test_autotrait" }, { - "name": "anyhow_device_test_tests_test_context" + "name": "anyhow_device_test_tests_test_boxed" }, { - "name": "libsqlite3-sys_device_test_src_lib" + "name": "anyhow_device_test_tests_test_chain" }, { - "name": "anyhow_device_test_tests_test_downcast" + "name": "anyhow_device_test_tests_test_context" }, { - "name": "keystore2_crypto_test_rust" + "name": "anyhow_device_test_tests_test_convert" }, { - "name": "anyhow_device_test_tests_test_convert" + "name": "anyhow_device_test_tests_test_downcast" }, { "name": "anyhow_device_test_tests_test_ffi" }, { - "name": "anyhow_device_test_tests_test_autotrait" + "name": "anyhow_device_test_tests_test_fmt" }, { "name": "anyhow_device_test_tests_test_macros" }, { - "name": "anyhow_device_test_tests_test_boxed" + "name": "anyhow_device_test_tests_test_repr" }, { - "name": "anyhow_device_test_tests_test_chain" + "name": "anyhow_device_test_tests_test_source" }, { - "name": "anyhow_device_test_src_lib" + "name": "keystore2_crypto_test_rust" }, { - "name": "anyhow_device_test_tests_test_source" + "name": "keystore2_selinux_concurrency_test" }, { - "name": "anyhow_device_test_tests_test_fmt" + "name": "keystore2_selinux_test" }, { - "name": "keystore2_selinux_test" + "name": "keystore2_test" + }, + { + "name": "vpnprofilestore_test" } ] } diff --git a/src/aserror.rs b/src/aserror.rs index 8290296..f440034 100644 --- a/src/aserror.rs +++ b/src/aserror.rs @@ -1,33 +1,33 @@ use std::error::Error; -pub trait AsDynError { - fn as_dyn_error(&self) -> &(dyn Error + 'static); +pub trait AsDynError<'a> { + fn as_dyn_error(&self) -> &(dyn Error + 'a); } -impl AsDynError for T { +impl<'a, T: Error + 'a> AsDynError<'a> for T { #[inline] - fn as_dyn_error(&self) -> &(dyn Error + 'static) { + fn as_dyn_error(&self) -> &(dyn Error + 'a) { self } } -impl AsDynError for dyn Error + 'static { +impl<'a> AsDynError<'a> for dyn Error + 'a { #[inline] - fn as_dyn_error(&self) -> &(dyn Error + 'static) { + fn as_dyn_error(&self) -> &(dyn Error + 'a) { self } } -impl AsDynError for dyn Error + Send + 'static { +impl<'a> AsDynError<'a> for dyn Error + Send + 'a { #[inline] - fn as_dyn_error(&self) -> &(dyn Error + 'static) { + fn as_dyn_error(&self) -> &(dyn Error + 'a) { self } } -impl AsDynError for dyn Error + Send + Sync + 'static { +impl<'a> AsDynError<'a> for dyn Error + Send + Sync + 'a { #[inline] - fn as_dyn_error(&self) -> &(dyn Error + 'static) { + fn as_dyn_error(&self) -> &(dyn Error + 'a) { self } } diff --git a/tests/test_source.rs b/tests/test_source.rs index 860e727..ab16097 100644 --- a/tests/test_source.rs +++ b/tests/test_source.rs @@ -60,4 +60,8 @@ macro_rules! error_from_macro { } // Test that we generate impls with the proper hygiene -error_from_macro!(#[error("Something")] Variant(#[from] io::Error)); +#[rustfmt::skip] +error_from_macro! { + #[error("Something")] + Variant(#[from] io::Error) +} diff --git a/tests/test_transparent.rs b/tests/test_transparent.rs index b862b25..84d7c91 100644 --- a/tests/test_transparent.rs +++ b/tests/test_transparent.rs @@ -57,3 +57,24 @@ fn test_anyhow() { assert_eq!("outer", error.to_string()); assert_eq!("inner", error.source().unwrap().to_string()); } + +#[test] +fn test_non_static() { + #[derive(Error, Debug)] + #[error(transparent)] + struct Error<'a> { + inner: ErrorKind<'a>, + } + + #[derive(Error, Debug)] + enum ErrorKind<'a> { + #[error("unexpected token: {:?}", token)] + Unexpected { token: &'a str }, + } + + let error = Error { + inner: ErrorKind::Unexpected { token: "error" }, + }; + assert_eq!("unexpected token: \"error\"", error.to_string()); + assert!(error.source().is_none()); +} diff --git a/tests/ui/concat-display.stderr b/tests/ui/concat-display.stderr index df1e19a..a009145 100644 --- a/tests/ui/concat-display.stderr +++ b/tests/ui/concat-display.stderr @@ -7,4 +7,4 @@ error: expected string literal 13 | error_type!(Error, "foo"); | -------------------------- in this macro invocation | - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `error_type` (in Nightly builds, run with -Z macro-backtrace for more info) -- cgit v1.2.3 From 7bd0dff2e9d74e7b12044c6b04006509a7bb81d7 Mon Sep 17 00:00:00 2001 From: easoncylee Date: Fri, 2 Jul 2021 11:33:57 +0800 Subject: Update vpnprofilestore_test to legacykeystore_test in TEST_MAPPING The test had been changed to legacykeystore_test from ag/14968529 Bug: 192796637 Test: presubmit Change-Id: Iff9030d3bf08d6a639bc6cc16bdc382306e5721a --- TEST_MAPPING | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TEST_MAPPING b/TEST_MAPPING index 254a499..41cb61a 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -50,7 +50,7 @@ "name": "keystore2_test" }, { - "name": "vpnprofilestore_test" + "name": "legacykeystore_test" } ] } -- cgit v1.2.3 From fd353153d7623f33dabc1b569276e8cc23facfdb Mon Sep 17 00:00:00 2001 From: Joel Galenson Date: Mon, 9 Aug 2021 10:47:02 -0700 Subject: Upgrade rust/crates/thiserror to 1.0.26 Test: make Change-Id: Ic58b588ecc9b6ae77c74002597a435d7a0f8dad2 --- .cargo_vcs_info.json | 2 +- Android.bp | 6 +++--- Cargo.toml | 4 ++-- Cargo.toml.orig | 4 ++-- METADATA | 8 ++++---- src/lib.rs | 6 +++++- tests/test_backtrace.rs | 4 ++++ tests/test_deprecated.rs | 10 ---------- tests/test_display.rs | 4 ++++ tests/test_expr.rs | 6 +++++- tests/test_from.rs | 4 ++++ tests/test_lints.rs | 5 +++++ tests/test_path.rs | 4 ++++ tests/test_source.rs | 4 ++++ tests/test_transparent.rs | 4 ++++ 15 files changed, 51 insertions(+), 24 deletions(-) delete mode 100644 tests/test_deprecated.rs diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index bc886ab..16f81ed 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "19cb5cee4b51203f6801daa3ff0185761d0d3d4c" + "sha1": "031fea6f3b82c72be11477e7550c6ae3579e6139" } } diff --git a/Android.bp b/Android.bp index 9212d3b..e369dc6 100644 --- a/Android.bp +++ b/Android.bp @@ -51,8 +51,8 @@ rust_library { } // dependent_library ["feature_list"] -// proc-macro2-1.0.27 "default,proc-macro" +// proc-macro2-1.0.28 "default,proc-macro" // quote-1.0.9 "default,proc-macro" -// syn-1.0.73 "clone-impls,default,derive,parsing,printing,proc-macro,quote" -// thiserror-impl-1.0.25 +// syn-1.0.74 "clone-impls,default,derive,parsing,printing,proc-macro,quote" +// thiserror-impl-1.0.26 // unicode-xid-0.2.2 "default" diff --git a/Cargo.toml b/Cargo.toml index 011dab7..c0da22c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ [package] edition = "2018" name = "thiserror" -version = "1.0.25" +version = "1.0.26" authors = ["David Tolnay "] 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.25" +version = "=1.0.26" [dev-dependencies.anyhow] version = "1.0" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 136c938..dd0b38e 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "thiserror" -version = "1.0.25" +version = "1.0.26" authors = ["David Tolnay "] edition = "2018" license = "MIT OR Apache-2.0" @@ -11,7 +11,7 @@ categories = ["rust-patterns"] readme = "README.md" [dependencies] -thiserror-impl = { version = "=1.0.25", path = "impl" } +thiserror-impl = { version = "=1.0.26", path = "impl" } [dev-dependencies] anyhow = "1.0" diff --git a/METADATA b/METADATA index f99aa6d..3b3c034 100644 --- a/METADATA +++ b/METADATA @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/thiserror/thiserror-1.0.25.crate" + value: "https://static.crates.io/crates/thiserror/thiserror-1.0.26.crate" } - version: "1.0.25" + version: "1.0.26" license_type: NOTICE last_upgrade_date { year: 2021 - month: 6 - day: 21 + month: 8 + day: 9 } } diff --git a/src/lib.rs b/src/lib.rs index 02941c8..11df494 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -185,7 +185,11 @@ //! //! [`anyhow`]: https://github.com/dtolnay/anyhow -#![allow(clippy::module_name_repetitions)] +#![allow( + // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7421 + clippy::doc_markdown, + clippy::module_name_repetitions, +)] mod aserror; mod display; diff --git a/tests/test_backtrace.rs b/tests/test_backtrace.rs index 09bc13d..c7ba3c4 100644 --- a/tests/test_backtrace.rs +++ b/tests/test_backtrace.rs @@ -1,4 +1,8 @@ #![cfg_attr(thiserror_nightly_testing, feature(backtrace))] +#![allow( + // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422 + clippy::nonstandard_macro_braces, +)] use thiserror::Error; diff --git a/tests/test_deprecated.rs b/tests/test_deprecated.rs deleted file mode 100644 index 5524666..0000000 --- a/tests/test_deprecated.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![deny(deprecated, clippy::all, clippy::pedantic)] - -use thiserror::Error; - -#[derive(Error, Debug)] -pub enum Error { - #[deprecated] - #[error("...")] - Deprecated, -} diff --git a/tests/test_display.rs b/tests/test_display.rs index 949d9ed..8a9ebf7 100644 --- a/tests/test_display.rs +++ b/tests/test_display.rs @@ -1,4 +1,8 @@ #![deny(clippy::all, clippy::pedantic)] +#![allow( + // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422 + clippy::nonstandard_macro_braces, +)] use std::fmt::Display; use thiserror::Error; diff --git a/tests/test_expr.rs b/tests/test_expr.rs index 87a56cf..50835a5 100644 --- a/tests/test_expr.rs +++ b/tests/test_expr.rs @@ -1,5 +1,9 @@ #![deny(clippy::all, clippy::pedantic)] -#![allow(clippy::option_if_let_else)] +#![allow( + // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422 + clippy::nonstandard_macro_braces, + clippy::option_if_let_else, +)] use std::fmt::Display; use thiserror::Error; diff --git a/tests/test_from.rs b/tests/test_from.rs index e8f0161..b6a3c0c 100644 --- a/tests/test_from.rs +++ b/tests/test_from.rs @@ -1,4 +1,8 @@ #![deny(clippy::all, clippy::pedantic)] +#![allow( + // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422 + clippy::nonstandard_macro_braces, +)] use std::io; use thiserror::Error; diff --git a/tests/test_lints.rs b/tests/test_lints.rs index 59699a4..457b799 100644 --- a/tests/test_lints.rs +++ b/tests/test_lints.rs @@ -1,3 +1,8 @@ +#![allow( + // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422 + clippy::nonstandard_macro_braces, +)] + use thiserror::Error; pub use std::error::Error; diff --git a/tests/test_path.rs b/tests/test_path.rs index a10b1f3..777b5de 100644 --- a/tests/test_path.rs +++ b/tests/test_path.rs @@ -1,4 +1,8 @@ #![deny(clippy::all, clippy::pedantic)] +#![allow( + // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422 + clippy::nonstandard_macro_braces, +)] use ref_cast::RefCast; use std::fmt::Display; diff --git a/tests/test_source.rs b/tests/test_source.rs index ab16097..c7ddda8 100644 --- a/tests/test_source.rs +++ b/tests/test_source.rs @@ -1,4 +1,8 @@ #![deny(clippy::all, clippy::pedantic)] +#![allow( + // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422 + clippy::nonstandard_macro_braces, +)] use std::error::Error as StdError; use std::io; diff --git a/tests/test_transparent.rs b/tests/test_transparent.rs index 84d7c91..7d02826 100644 --- a/tests/test_transparent.rs +++ b/tests/test_transparent.rs @@ -1,4 +1,8 @@ #![deny(clippy::all, clippy::pedantic)] +#![allow( + // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422 + clippy::nonstandard_macro_braces, +)] use anyhow::anyhow; use std::error::Error as _; -- cgit v1.2.3 From 371b614dee4c8e0f594b0d7ebb11b05a5eb130b1 Mon Sep 17 00:00:00 2001 From: Joel Galenson Date: Mon, 23 Aug 2021 10:40:45 -0700 Subject: Update TEST_MAPPING Test: None Change-Id: If6c39c289e40e5cc758b0960a2e92feae86effa0 --- TEST_MAPPING | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/TEST_MAPPING b/TEST_MAPPING index 41cb61a..53f25ab 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -1,6 +1,9 @@ // Generated by update_crate_tests.py for tests that depend on this crate. { "presubmit": [ + { + "name": "ZipFuseTest" + }, { "name": "anyhow_device_test_src_lib" }, @@ -37,6 +40,57 @@ { "name": "anyhow_device_test_tests_test_source" }, + { + "name": "authfs_device_test_src_lib" + }, + { + "name": "jni_device_test_src_lib" + }, + { + "name": "jni_device_test_tests_executor" + }, + { + "name": "jni_device_test_tests_executor_nested_attach" + }, + { + "name": "jni_device_test_tests_java_integers" + }, + { + "name": "jni_device_test_tests_jmap" + }, + { + "name": "jni_device_test_tests_jni_api" + }, + { + "name": "jni_device_test_tests_jni_global_refs" + }, + { + "name": "jni_device_test_tests_threads_attach_guard" + }, + { + "name": "jni_device_test_tests_threads_detach" + }, + { + "name": "jni_device_test_tests_threads_detach_daemon" + }, + { + "name": "jni_device_test_tests_threads_explicit_detach" + }, + { + "name": "jni_device_test_tests_threads_explicit_detach_daemon" + }, + { + "name": "jni_device_test_tests_threads_explicit_detach_permanent" + }, + { + "name": "jni_device_test_tests_threads_nested_attach_daemon" + }, + { + "name": "jni_device_test_tests_threads_nested_attach_guard" + }, + { + "name": "jni_device_test_tests_threads_nested_attach_permanently" + }, { "name": "keystore2_crypto_test_rust" }, @@ -51,6 +105,24 @@ }, { "name": "legacykeystore_test" + }, + { + "name": "libapkverify.integration_test" + }, + { + "name": "libapkverify.test" + }, + { + "name": "microdroid_manager_test" + }, + { + "name": "serde-xml-rs_device_test_src_lib" + }, + { + "name": "serde-xml-rs_device_test_tests_round_trip" + }, + { + "name": "virtualizationservice_device_test" } ] } -- cgit v1.2.3 From d3ed325f983140fca63adef0ab52b1100f0362c2 Mon Sep 17 00:00:00 2001 From: Joel Galenson Date: Wed, 22 Sep 2021 11:24:03 -0700 Subject: Upgrade rust/crates/thiserror to 1.0.29 Test: make Change-Id: I6abd1fcf8199ea5b50c14f2138d25555374c5375 --- .cargo_vcs_info.json | 2 +- Android.bp | 9 +-- Cargo.toml | 13 ++-- Cargo.toml.orig | 4 +- METADATA | 8 +-- README.md | 14 ++++ src/lib.rs | 16 +++++ tests/test_backtrace.rs | 43 +++++++++++-- tests/test_display.rs | 4 -- tests/test_expr.rs | 6 +- tests/test_from.rs | 27 ++++++-- tests/test_generics.rs | 161 ++++++++++++++++++++++++++++++++++++++++++++++ tests/test_lints.rs | 5 -- tests/test_path.rs | 4 -- tests/test_source.rs | 4 -- tests/test_transparent.rs | 4 -- 16 files changed, 267 insertions(+), 57 deletions(-) create mode 100644 tests/test_generics.rs diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 16f81ed..d146052 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "031fea6f3b82c72be11477e7550c6ae3579e6139" + "sha1": "c7dd271dcd92af17168746a809503ee392d6f6ad" } } diff --git a/Android.bp b/Android.bp index e369dc6..0c3bbe8 100644 --- a/Android.bp +++ b/Android.bp @@ -41,6 +41,8 @@ rust_library { name: "libthiserror", host_supported: true, crate_name: "thiserror", + cargo_env_compat: true, + cargo_pkg_version: "1.0.29", srcs: ["src/lib.rs"], edition: "2018", proc_macros: ["libthiserror_impl"], @@ -49,10 +51,3 @@ rust_library { "com.android.virt", ], } - -// dependent_library ["feature_list"] -// proc-macro2-1.0.28 "default,proc-macro" -// quote-1.0.9 "default,proc-macro" -// syn-1.0.74 "clone-impls,default,derive,parsing,printing,proc-macro,quote" -// thiserror-impl-1.0.26 -// unicode-xid-0.2.2 "default" diff --git a/Cargo.toml b/Cargo.toml index c0da22c..ea80376 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,17 +3,16 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "thiserror" -version = "1.0.26" +version = "1.0.29" authors = ["David Tolnay "] description = "derive(Error)" documentation = "https://docs.rs/thiserror" @@ -24,7 +23,7 @@ repository = "https://github.com/dtolnay/thiserror" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] [dependencies.thiserror-impl] -version = "=1.0.26" +version = "=1.0.29" [dev-dependencies.anyhow] version = "1.0" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index dd0b38e..f619245 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "thiserror" -version = "1.0.26" +version = "1.0.29" authors = ["David Tolnay "] edition = "2018" license = "MIT OR Apache-2.0" @@ -11,7 +11,7 @@ categories = ["rust-patterns"] readme = "README.md" [dependencies] -thiserror-impl = { version = "=1.0.26", path = "impl" } +thiserror-impl = { version = "=1.0.29", path = "impl" } [dev-dependencies] anyhow = "1.0" diff --git a/METADATA b/METADATA index 3b3c034..6f9cb40 100644 --- a/METADATA +++ b/METADATA @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/thiserror/thiserror-1.0.26.crate" + value: "https://static.crates.io/crates/thiserror/thiserror-1.0.29.crate" } - version: "1.0.26" + version: "1.0.29" license_type: NOTICE last_upgrade_date { year: 2021 - month: 8 - day: 9 + month: 9 + day: 22 } } diff --git a/README.md b/README.md index 76c436a..e12b693 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,20 @@ pub enum DataStoreError { } ``` +- If a field is both a source (named `source`, or has `#[source]` or `#[from]` + attribute) *and* is marked `#[backtrace]`, then the Error trait's + `backtrace()` method is forwarded to the source's backtrace. + + ```rust + #[derive(Error, Debug)] + pub enum MyError { + Io { + #[backtrace] + source: io::Error, + }, + } + ``` + - Errors may use `error(transparent)` to forward the source and Display methods straight through to an underlying error without adding an additional message. This would be appropriate for enums that need an "anything else" variant. diff --git a/src/lib.rs b/src/lib.rs index 11df494..2fae25c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -161,6 +161,22 @@ //! # }; //! ``` //! +//! - If a field is both a source (named `source`, or has `#[source]` or +//! `#[from]` attribute) *and* is marked `#[backtrace]`, then the Error +//! trait's `backtrace()` method is forwarded to the source's backtrace. +//! +//! ```rust +//! # const IGNORE: &str = stringify! { +//! #[derive(Error, Debug)] +//! pub enum MyError { +//! Io { +//! #[backtrace] +//! source: io::Error, +//! }, +//! } +//! # }; +//! ``` +//! //! - Errors may use `error(transparent)` to forward the source and Display //! methods straight through to an underlying error without adding an //! additional message. This would be appropriate for enums that need an diff --git a/tests/test_backtrace.rs b/tests/test_backtrace.rs index c7ba3c4..42e37ca 100644 --- a/tests/test_backtrace.rs +++ b/tests/test_backtrace.rs @@ -1,8 +1,4 @@ #![cfg_attr(thiserror_nightly_testing, feature(backtrace))] -#![allow( - // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422 - clippy::nonstandard_macro_braces, -)] use thiserror::Error; @@ -10,9 +6,16 @@ use thiserror::Error; #[error("...")] pub struct Inner; +#[cfg(thiserror_nightly_testing)] +#[derive(Error, Debug)] +#[error("...")] +pub struct InnerBacktrace { + backtrace: std::backtrace::Backtrace, +} + #[cfg(thiserror_nightly_testing)] pub mod structs { - use super::Inner; + use super::{Inner, InnerBacktrace}; use std::backtrace::Backtrace; use std::error::Error; use std::sync::Arc; @@ -54,6 +57,14 @@ pub mod structs { backtrace: Backtrace, } + #[derive(Error, Debug)] + #[error("...")] + pub struct CombinedBacktraceFrom { + #[from] + #[backtrace] + source: InnerBacktrace, + } + #[derive(Error, Debug)] #[error("...")] pub struct OptBacktraceFrom { @@ -97,6 +108,11 @@ pub mod structs { let error = BacktraceFrom::from(Inner); assert!(error.backtrace().is_some()); + let error = CombinedBacktraceFrom::from(InnerBacktrace { + backtrace: Backtrace::capture(), + }); + assert!(error.backtrace().is_some()); + let error = OptBacktraceFrom::from(Inner); assert!(error.backtrace().is_some()); @@ -107,7 +123,7 @@ pub mod structs { #[cfg(thiserror_nightly_testing)] pub mod enums { - use super::Inner; + use super::{Inner, InnerBacktrace}; use std::backtrace::Backtrace; use std::error::Error; use std::sync::Arc; @@ -157,6 +173,16 @@ pub mod enums { }, } + #[derive(Error, Debug)] + pub enum CombinedBacktraceFrom { + #[error("...")] + Test { + #[from] + #[backtrace] + source: InnerBacktrace, + }, + } + #[derive(Error, Debug)] pub enum OptBacktraceFrom { #[error("...")] @@ -204,6 +230,11 @@ pub mod enums { let error = BacktraceFrom::from(Inner); assert!(error.backtrace().is_some()); + let error = CombinedBacktraceFrom::from(InnerBacktrace { + backtrace: Backtrace::capture(), + }); + assert!(error.backtrace().is_some()); + let error = OptBacktraceFrom::from(Inner); assert!(error.backtrace().is_some()); diff --git a/tests/test_display.rs b/tests/test_display.rs index 8a9ebf7..949d9ed 100644 --- a/tests/test_display.rs +++ b/tests/test_display.rs @@ -1,8 +1,4 @@ #![deny(clippy::all, clippy::pedantic)] -#![allow( - // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422 - clippy::nonstandard_macro_braces, -)] use std::fmt::Display; use thiserror::Error; diff --git a/tests/test_expr.rs b/tests/test_expr.rs index 50835a5..87a56cf 100644 --- a/tests/test_expr.rs +++ b/tests/test_expr.rs @@ -1,9 +1,5 @@ #![deny(clippy::all, clippy::pedantic)] -#![allow( - // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422 - clippy::nonstandard_macro_braces, - clippy::option_if_let_else, -)] +#![allow(clippy::option_if_let_else)] use std::fmt::Display; use thiserror::Error; diff --git a/tests/test_from.rs b/tests/test_from.rs index b6a3c0c..a25ce35 100644 --- a/tests/test_from.rs +++ b/tests/test_from.rs @@ -1,8 +1,4 @@ #![deny(clippy::all, clippy::pedantic)] -#![allow( - // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422 - clippy::nonstandard_macro_braces, -)] use std::io; use thiserror::Error; @@ -14,10 +10,21 @@ pub struct ErrorStruct { source: io::Error, } +#[derive(Error, Debug)] +#[error("...")] +pub struct ErrorStructOptional { + #[from] + source: Option, +} + #[derive(Error, Debug)] #[error("...")] pub struct ErrorTuple(#[from] io::Error); +#[derive(Error, Debug)] +#[error("...")] +pub struct ErrorTupleOptional(#[from] Option); + #[derive(Error, Debug)] #[error("...")] pub enum ErrorEnum { @@ -27,6 +34,15 @@ pub enum ErrorEnum { }, } +#[derive(Error, Debug)] +#[error("...")] +pub enum ErrorEnumOptional { + Test { + #[from] + source: Option, + }, +} + #[derive(Error, Debug)] #[error("...")] pub enum Many { @@ -39,7 +55,10 @@ fn assert_impl>() {} #[test] fn test_from() { assert_impl::(); + assert_impl::(); assert_impl::(); + assert_impl::(); assert_impl::(); + assert_impl::(); assert_impl::(); } diff --git a/tests/test_generics.rs b/tests/test_generics.rs new file mode 100644 index 0000000..f5e1de2 --- /dev/null +++ b/tests/test_generics.rs @@ -0,0 +1,161 @@ +#![deny(clippy::all, clippy::pedantic)] + +use std::fmt::{self, Debug, Display}; +use thiserror::Error; + +pub struct NoFormat; + +#[derive(Debug)] +pub struct DebugOnly; + +pub struct DisplayOnly; + +impl Display for DisplayOnly { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str("display only") + } +} + +#[derive(Debug)] +pub struct DebugAndDisplay; + +impl Display for DebugAndDisplay { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str("debug and display") + } +} + +// Should expand to: +// +// impl Display for EnumDebugField +// where +// E: Debug; +// +// impl Error for EnumDebugField +// where +// Self: Debug + Display; +// +#[derive(Error, Debug)] +pub enum EnumDebugGeneric { + #[error("{0:?}")] + FatalError(E), +} + +// Should expand to: +// +// impl Display for EnumFromGeneric; +// +// impl Error for EnumFromGeneric +// where +// EnumDebugGeneric: Error + 'static, +// Self: Debug + Display; +// +#[derive(Error, Debug)] +pub enum EnumFromGeneric { + #[error("enum from generic")] + Source(#[from] EnumDebugGeneric), +} + +// Should expand to: +// +// impl Display +// for EnumCompound +// where +// HasDisplay: Display, +// HasDebug: Debug; +// +// impl Error +// for EnumCompound +// where +// Self: Debug + Display; +// +#[derive(Error)] +pub enum EnumCompound { + #[error("{0} {1:?}")] + DisplayDebug(HasDisplay, HasDebug), + #[error("{0}")] + Display(HasDisplay, HasNeither), + #[error("{1:?}")] + Debug(HasNeither, HasDebug), +} + +impl Debug for EnumCompound { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str("EnumCompound") + } +} + +#[test] +fn test_display_enum_compound() { + let mut instance: EnumCompound; + + instance = EnumCompound::DisplayDebug(DisplayOnly, DebugOnly); + assert_eq!(format!("{}", instance), "display only DebugOnly"); + + instance = EnumCompound::Display(DisplayOnly, NoFormat); + assert_eq!(format!("{}", instance), "display only"); + + instance = EnumCompound::Debug(NoFormat, DebugOnly); + assert_eq!(format!("{}", instance), "DebugOnly"); +} + +// Should expand to: +// +// impl Display for EnumTransparentGeneric +// where +// E: Display; +// +// impl Error for EnumTransparentGeneric +// where +// E: Error, +// Self: Debug + Display; +// +#[derive(Error, Debug)] +pub enum EnumTransparentGeneric { + #[error(transparent)] + Other(E), +} + +// Should expand to: +// +// impl Display for StructDebugGeneric +// where +// E: Debug; +// +// impl Error for StructDebugGeneric +// where +// Self: Debug + Display; +// +#[derive(Error, Debug)] +#[error("{underlying:?}")] +pub struct StructDebugGeneric { + pub underlying: E, +} + +// Should expand to: +// +// impl Error for StructFromGeneric +// where +// StructDebugGeneric: Error + 'static, +// Self: Debug + Display; +// +#[derive(Error, Debug)] +pub struct StructFromGeneric { + #[from] + pub source: StructDebugGeneric, +} + +// Should expand to: +// +// impl Display for StructTransparentGeneric +// where +// E: Display; +// +// impl Error for StructTransparentGeneric +// where +// E: Error, +// Self: Debug + Display; +// +#[derive(Error, Debug)] +#[error(transparent)] +pub struct StructTransparentGeneric(E); diff --git a/tests/test_lints.rs b/tests/test_lints.rs index 457b799..59699a4 100644 --- a/tests/test_lints.rs +++ b/tests/test_lints.rs @@ -1,8 +1,3 @@ -#![allow( - // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422 - clippy::nonstandard_macro_braces, -)] - use thiserror::Error; pub use std::error::Error; diff --git a/tests/test_path.rs b/tests/test_path.rs index 777b5de..a10b1f3 100644 --- a/tests/test_path.rs +++ b/tests/test_path.rs @@ -1,8 +1,4 @@ #![deny(clippy::all, clippy::pedantic)] -#![allow( - // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422 - clippy::nonstandard_macro_braces, -)] use ref_cast::RefCast; use std::fmt::Display; diff --git a/tests/test_source.rs b/tests/test_source.rs index c7ddda8..ab16097 100644 --- a/tests/test_source.rs +++ b/tests/test_source.rs @@ -1,8 +1,4 @@ #![deny(clippy::all, clippy::pedantic)] -#![allow( - // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422 - clippy::nonstandard_macro_braces, -)] use std::error::Error as StdError; use std::io; diff --git a/tests/test_transparent.rs b/tests/test_transparent.rs index 7d02826..84d7c91 100644 --- a/tests/test_transparent.rs +++ b/tests/test_transparent.rs @@ -1,8 +1,4 @@ #![deny(clippy::all, clippy::pedantic)] -#![allow( - // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422 - clippy::nonstandard_macro_braces, -)] use anyhow::anyhow; use std::error::Error as _; -- cgit v1.2.3 From 48af3adb9f409299c64b320eebba171ade47560a Mon Sep 17 00:00:00 2001 From: Alan Stokes Date: Wed, 29 Sep 2021 12:33:21 +0100 Subject: Grant visibility to the CompOS APEX. This is needed as a dependency of cxx. Bug: 186126194 Test: Builds Change-Id: I31c6aced2ad1a164883f04164a318aeb02621f04 --- Android.bp | 1 + cargo2android.json | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Android.bp b/Android.bp index e369dc6..298cae1 100644 --- a/Android.bp +++ b/Android.bp @@ -46,6 +46,7 @@ rust_library { proc_macros: ["libthiserror_impl"], apex_available: [ "//apex_available:platform", + "com.android.compos", "com.android.virt", ], } diff --git a/cargo2android.json b/cargo2android.json index 42b7833..c75649c 100644 --- a/cargo2android.json +++ b/cargo2android.json @@ -1,9 +1,10 @@ { "apex-available": [ "//apex_available:platform", + "com.android.compos", "com.android.virt" ], "dependencies": true, "device": true, "run": true -} \ No newline at end of file +} -- cgit v1.2.3 From 8b58b81ee81b7206aec8b8821c8ac4fe367f3326 Mon Sep 17 00:00:00 2001 From: Joel Galenson Date: Fri, 1 Oct 2021 07:15:05 -0700 Subject: Update TEST_MAPPING Test: None Change-Id: Ib5124ce80ee2735aee2f893bc24fb803c29701c0 --- TEST_MAPPING | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/TEST_MAPPING b/TEST_MAPPING index 53f25ab..35b2201 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -40,6 +40,9 @@ { "name": "anyhow_device_test_tests_test_source" }, + { + "name": "apkdmverity.test" + }, { "name": "authfs_device_test_src_lib" }, @@ -103,6 +106,12 @@ { "name": "keystore2_test" }, + { + "name": "keystore2_test_utils_test" + }, + { + "name": "keystore2_vintf_test" + }, { "name": "legacykeystore_test" }, @@ -118,9 +127,6 @@ { "name": "serde-xml-rs_device_test_src_lib" }, - { - "name": "serde-xml-rs_device_test_tests_round_trip" - }, { "name": "virtualizationservice_device_test" } -- cgit v1.2.3 From f54d531dd3fa0dfa4b78c0cbdda7ba2fd05f0d7b Mon Sep 17 00:00:00 2001 From: Matthew Maurer Date: Tue, 19 Oct 2021 13:19:19 -0700 Subject: Make thiserror available to DNS Resolver Bug: 202081046 Test: New DNS Resolver code builds Change-Id: Idb1b63202f12c3514010ef97be502789052a2551 --- Android.bp | 2 ++ cargo2android.json | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Android.bp b/Android.bp index f71b8f0..d4c0eca 100644 --- a/Android.bp +++ b/Android.bp @@ -49,6 +49,8 @@ rust_library { apex_available: [ "//apex_available:platform", "com.android.compos", + "com.android.resolv", "com.android.virt", ], + min_sdk_version: "29", } diff --git a/cargo2android.json b/cargo2android.json index c75649c..4f20b80 100644 --- a/cargo2android.json +++ b/cargo2android.json @@ -2,9 +2,11 @@ "apex-available": [ "//apex_available:platform", "com.android.compos", + "com.android.resolv", "com.android.virt" ], "dependencies": true, "device": true, + "min_sdk_version": "29", "run": true } -- cgit v1.2.3 From 418614426111ed6f2d776a0290b1097c22e3da60 Mon Sep 17 00:00:00 2001 From: Joel Galenson Date: Thu, 28 Oct 2021 15:30:49 -0700 Subject: Add apex_available. Test: None Change-Id: I3b6d201f7020ea72493aaf3f3cc45eb40207c902 --- Android.bp | 1 + cargo2android.json | 1 + 2 files changed, 2 insertions(+) diff --git a/Android.bp b/Android.bp index d4c0eca..dd0eac2 100644 --- a/Android.bp +++ b/Android.bp @@ -50,6 +50,7 @@ rust_library { "//apex_available:platform", "com.android.compos", "com.android.resolv", + "com.android.uwb", "com.android.virt", ], min_sdk_version: "29", diff --git a/cargo2android.json b/cargo2android.json index 4f20b80..e7da217 100644 --- a/cargo2android.json +++ b/cargo2android.json @@ -3,6 +3,7 @@ "//apex_available:platform", "com.android.compos", "com.android.resolv", + "com.android.uwb", "com.android.virt" ], "dependencies": true, -- cgit v1.2.3 From eab3d3bb5cef765b71b83e7ed86af849be3675d4 Mon Sep 17 00:00:00 2001 From: Janis Danisevskis Date: Wed, 10 Nov 2021 10:07:48 -0800 Subject: Make vendor available. Bug: 198197213 Test: N/A Change-Id: I4aae955da6600a41759a68307c81e67ecc7d6f1c --- Android.bp | 1 + cargo2android.json | 1 + 2 files changed, 2 insertions(+) diff --git a/Android.bp b/Android.bp index dd0eac2..226e160 100644 --- a/Android.bp +++ b/Android.bp @@ -40,6 +40,7 @@ license { rust_library { name: "libthiserror", host_supported: true, + vendor_available: true, crate_name: "thiserror", cargo_env_compat: true, cargo_pkg_version: "1.0.29", diff --git a/cargo2android.json b/cargo2android.json index e7da217..8d63324 100644 --- a/cargo2android.json +++ b/cargo2android.json @@ -9,5 +9,6 @@ "dependencies": true, "device": true, "min_sdk_version": "29", + "vendor_available": true, "run": true } -- cgit v1.2.3 From 6ca76359f352f3c1db0222fcf01a9071bb41c597 Mon Sep 17 00:00:00 2001 From: Joel Galenson Date: Mon, 29 Nov 2021 14:05:35 -0800 Subject: Refresh Android.bp, cargo2android.json, TEST_MAPPING. Test: None Change-Id: Iec1c814f18a0c84fe2d5d9f6b88fc6d5496f7fa6 --- Android.bp | 2 +- TEST_MAPPING | 80 ++++++++++++++++++++---------------------------------- cargo2android.json | 8 +++--- 3 files changed, 35 insertions(+), 55 deletions(-) diff --git a/Android.bp b/Android.bp index 226e160..cc2e6d6 100644 --- a/Android.bp +++ b/Android.bp @@ -40,7 +40,6 @@ license { rust_library { name: "libthiserror", host_supported: true, - vendor_available: true, crate_name: "thiserror", cargo_env_compat: true, cargo_pkg_version: "1.0.29", @@ -54,5 +53,6 @@ rust_library { "com.android.uwb", "com.android.virt", ], + vendor_available: true, min_sdk_version: "29", } diff --git a/TEST_MAPPING b/TEST_MAPPING index 35b2201..ec89789 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -1,44 +1,19 @@ // Generated by update_crate_tests.py for tests that depend on this crate. { - "presubmit": [ - { - "name": "ZipFuseTest" - }, - { - "name": "anyhow_device_test_src_lib" - }, - { - "name": "anyhow_device_test_tests_test_autotrait" - }, - { - "name": "anyhow_device_test_tests_test_boxed" - }, - { - "name": "anyhow_device_test_tests_test_chain" - }, - { - "name": "anyhow_device_test_tests_test_context" - }, - { - "name": "anyhow_device_test_tests_test_convert" - }, - { - "name": "anyhow_device_test_tests_test_downcast" - }, - { - "name": "anyhow_device_test_tests_test_ffi" - }, + "imports": [ { - "name": "anyhow_device_test_tests_test_fmt" + "path": "external/rust/crates/anyhow" }, { - "name": "anyhow_device_test_tests_test_macros" + "path": "external/rust/crates/jni" }, { - "name": "anyhow_device_test_tests_test_repr" - }, + "path": "external/rust/crates/serde-xml-rs" + } + ], + "presubmit": [ { - "name": "anyhow_device_test_tests_test_source" + "name": "ZipFuseTest" }, { "name": "apkdmverity.test" @@ -47,52 +22,57 @@ "name": "authfs_device_test_src_lib" }, { - "name": "jni_device_test_src_lib" + "name": "doh_unit_test" }, { - "name": "jni_device_test_tests_executor" + "name": "keystore2_crypto_test_rust" }, { - "name": "jni_device_test_tests_executor_nested_attach" + "name": "keystore2_selinux_concurrency_test" }, { - "name": "jni_device_test_tests_java_integers" + "name": "keystore2_selinux_test" }, { - "name": "jni_device_test_tests_jmap" + "name": "keystore2_test" }, { - "name": "jni_device_test_tests_jni_api" + "name": "keystore2_test_utils_test" }, { - "name": "jni_device_test_tests_jni_global_refs" + "name": "keystore2_vintf_test" }, { - "name": "jni_device_test_tests_threads_attach_guard" + "name": "legacykeystore_test" }, { - "name": "jni_device_test_tests_threads_detach" + "name": "libapkverify.integration_test" }, { - "name": "jni_device_test_tests_threads_detach_daemon" + "name": "libapkverify.test" }, { - "name": "jni_device_test_tests_threads_explicit_detach" + "name": "microdroid_manager_test" }, { - "name": "jni_device_test_tests_threads_explicit_detach_daemon" + "name": "open_then_run_module" }, { - "name": "jni_device_test_tests_threads_explicit_detach_permanent" + "name": "virtualizationservice_device_test" + } + ], + "presubmit-rust": [ + { + "name": "ZipFuseTest" }, { - "name": "jni_device_test_tests_threads_nested_attach_daemon" + "name": "apkdmverity.test" }, { - "name": "jni_device_test_tests_threads_nested_attach_guard" + "name": "authfs_device_test_src_lib" }, { - "name": "jni_device_test_tests_threads_nested_attach_permanently" + "name": "doh_unit_test" }, { "name": "keystore2_crypto_test_rust" @@ -125,7 +105,7 @@ "name": "microdroid_manager_test" }, { - "name": "serde-xml-rs_device_test_src_lib" + "name": "open_then_run_module" }, { "name": "virtualizationservice_device_test" diff --git a/cargo2android.json b/cargo2android.json index 8d63324..968e19b 100644 --- a/cargo2android.json +++ b/cargo2android.json @@ -8,7 +8,7 @@ ], "dependencies": true, "device": true, - "min_sdk_version": "29", - "vendor_available": true, - "run": true -} + "min-sdk-version": "29", + "run": true, + "vendor-available": true +} \ No newline at end of file -- cgit v1.2.3 From bb92c96110d817f8d7c726d097bb4c12af9e9852 Mon Sep 17 00:00:00 2001 From: Roopa Sattiraju Date: Tue, 21 Dec 2021 17:28:00 -0800 Subject: Adding bluetooth apex Bug: 206121418 Test: Compile Change-Id: I9c98b9a12cbfb99a4465a1eae7b8103ba1f7f4fb --- Android.bp | 1 + cargo2android.json | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Android.bp b/Android.bp index cc2e6d6..9db6ce8 100644 --- a/Android.bp +++ b/Android.bp @@ -48,6 +48,7 @@ rust_library { proc_macros: ["libthiserror_impl"], apex_available: [ "//apex_available:platform", + "com.android.bluetooth", "com.android.compos", "com.android.resolv", "com.android.uwb", diff --git a/cargo2android.json b/cargo2android.json index 968e19b..9a52406 100644 --- a/cargo2android.json +++ b/cargo2android.json @@ -1,6 +1,7 @@ { "apex-available": [ "//apex_available:platform", + "com.android.bluetooth", "com.android.compos", "com.android.resolv", "com.android.uwb", @@ -11,4 +12,4 @@ "min-sdk-version": "29", "run": true, "vendor-available": true -} \ No newline at end of file +} -- cgit v1.2.3 From 63585e47cad09307c6bfadc8a50e69089ab18e71 Mon Sep 17 00:00:00 2001 From: David LeGare Date: Wed, 2 Mar 2022 16:21:05 +0000 Subject: Update thiserror to 1.0.30 Test: cd external/rust/crates && atest --host -c Change-Id: I4ddc83248e810495312f98955f7ed61c3271273b --- .cargo_vcs_info.json | 7 +++--- .github/workflows/ci.yml | 10 ++++++++ Android.bp | 2 +- Cargo.toml | 7 +++--- Cargo.toml.orig | 7 +++--- METADATA | 10 ++++---- rust-toolchain.toml | 2 ++ src/aserror.rs | 8 ++++++ tests/ui/bad-field-attr.stderr | 2 +- tests/ui/concat-display.stderr | 2 +- tests/ui/duplicate-enum-source.stderr | 2 +- tests/ui/duplicate-fmt.stderr | 2 +- tests/ui/duplicate-struct-source.stderr | 2 +- tests/ui/duplicate-transparent.stderr | 2 +- tests/ui/from-not-source.stderr | 2 +- tests/ui/lifetime.stderr | 4 +-- tests/ui/missing-fmt.stderr | 2 +- tests/ui/no-display.stderr | 31 +++++++++++++++-------- tests/ui/source-enum-not-error.stderr | 41 ++++++++++++++++++++----------- tests/ui/source-struct-not-error.stderr | 39 ++++++++++++++++++----------- tests/ui/transparent-display.stderr | 2 +- tests/ui/transparent-enum-many.stderr | 2 +- tests/ui/transparent-enum-source.stderr | 2 +- tests/ui/transparent-struct-many.stderr | 2 +- tests/ui/transparent-struct-source.stderr | 2 +- tests/ui/unexpected-field-fmt.stderr | 2 +- tests/ui/unexpected-struct-source.stderr | 2 +- tests/ui/union.stderr | 2 +- 28 files changed, 128 insertions(+), 72 deletions(-) create mode 100644 rust-toolchain.toml diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index d146052..cafa20e 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,6 @@ { "git": { - "sha1": "c7dd271dcd92af17168746a809503ee392d6f6ad" - } -} + "sha1": "672e9525bbc2e5682c380d36974f34716b963591" + }, + "path_in_vcs": "" +} \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 263e04c..61714b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: toolchain: ${{matrix.rust}} + components: rust-src - run: cargo test --all env: RUSTFLAGS: ${{matrix.rustflags}} @@ -36,7 +37,16 @@ jobs: clippy: name: Clippy runs-on: ubuntu-latest + if: github.event_name != 'pull_request' steps: - uses: actions/checkout@v2 - uses: dtolnay/rust-toolchain@clippy - run: cargo clippy --tests -- -Dclippy::all -Dclippy::pedantic + + outdated: + name: Outdated + runs-on: ubuntu-latest + if: github.event_name != 'pull_request' + steps: + - uses: actions/checkout@v2 + - run: cargo outdated --exit-code 1 diff --git a/Android.bp b/Android.bp index 9db6ce8..b1dc159 100644 --- a/Android.bp +++ b/Android.bp @@ -42,7 +42,7 @@ rust_library { host_supported: true, crate_name: "thiserror", cargo_env_compat: true, - cargo_pkg_version: "1.0.29", + cargo_pkg_version: "1.0.30", srcs: ["src/lib.rs"], edition: "2018", proc_macros: ["libthiserror_impl"], diff --git a/Cargo.toml b/Cargo.toml index ea80376..78c99d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,8 +11,9 @@ [package] edition = "2018" +rust-version = "1.31" name = "thiserror" -version = "1.0.29" +version = "1.0.30" authors = ["David Tolnay "] description = "derive(Error)" documentation = "https://docs.rs/thiserror" @@ -23,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.29" +version = "=1.0.30" [dev-dependencies.anyhow] version = "1.0" @@ -34,5 +35,5 @@ version = "1.0" version = "1.0" [dev-dependencies.trybuild] -version = "1.0.19" +version = "1.0.49" features = ["diff"] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index f619245..efa9af1 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,8 +1,9 @@ [package] name = "thiserror" -version = "1.0.29" +version = "1.0.30" authors = ["David Tolnay "] edition = "2018" +rust-version = "1.31" license = "MIT OR Apache-2.0" description = "derive(Error)" repository = "https://github.com/dtolnay/thiserror" @@ -11,13 +12,13 @@ categories = ["rust-patterns"] readme = "README.md" [dependencies] -thiserror-impl = { version = "=1.0.29", path = "impl" } +thiserror-impl = { version = "=1.0.30", path = "impl" } [dev-dependencies] anyhow = "1.0" ref-cast = "1.0" rustversion = "1.0" -trybuild = { version = "1.0.19", features = ["diff"] } +trybuild = { version = "1.0.49", features = ["diff"] } [workspace] members = ["impl"] diff --git a/METADATA b/METADATA index 6f9cb40..e961418 100644 --- a/METADATA +++ b/METADATA @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/thiserror/thiserror-1.0.29.crate" + value: "https://static.crates.io/crates/thiserror/thiserror-1.0.30.crate" } - version: "1.0.29" + version: "1.0.30" license_type: NOTICE last_upgrade_date { - year: 2021 - month: 9 - day: 22 + year: 2022 + month: 3 + day: 1 } } diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..20fe888 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +components = ["rust-src"] diff --git a/src/aserror.rs b/src/aserror.rs index f440034..c036b7b 100644 --- a/src/aserror.rs +++ b/src/aserror.rs @@ -1,4 +1,5 @@ use std::error::Error; +use std::panic::UnwindSafe; pub trait AsDynError<'a> { fn as_dyn_error(&self) -> &(dyn Error + 'a); @@ -31,3 +32,10 @@ impl<'a> AsDynError<'a> for dyn Error + Send + Sync + 'a { self } } + +impl<'a> AsDynError<'a> for dyn Error + Send + Sync + UnwindSafe + 'a { + #[inline] + fn as_dyn_error(&self) -> &(dyn Error + 'a) { + self + } +} diff --git a/tests/ui/bad-field-attr.stderr b/tests/ui/bad-field-attr.stderr index ecc4702..5fb5744 100644 --- a/tests/ui/bad-field-attr.stderr +++ b/tests/ui/bad-field-attr.stderr @@ -1,5 +1,5 @@ error: #[error(transparent)] needs to go outside the enum or struct, not on an individual field - --> $DIR/bad-field-attr.rs:5:18 + --> tests/ui/bad-field-attr.rs:5:18 | 5 | pub struct Error(#[error(transparent)] std::io::Error); | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/concat-display.stderr b/tests/ui/concat-display.stderr index a009145..6ab4048 100644 --- a/tests/ui/concat-display.stderr +++ b/tests/ui/concat-display.stderr @@ -1,5 +1,5 @@ error: expected string literal - --> $DIR/concat-display.rs:8:17 + --> tests/ui/concat-display.rs:8:17 | 8 | #[error(concat!("invalid ", $what))] | ^^^^^^ diff --git a/tests/ui/duplicate-enum-source.stderr b/tests/ui/duplicate-enum-source.stderr index 55d81be..4a4b2d3 100644 --- a/tests/ui/duplicate-enum-source.stderr +++ b/tests/ui/duplicate-enum-source.stderr @@ -1,5 +1,5 @@ error: duplicate #[source] attribute - --> $DIR/duplicate-enum-source.rs:8:9 + --> tests/ui/duplicate-enum-source.rs:8:9 | 8 | #[source] | ^^^^^^^^^ diff --git a/tests/ui/duplicate-fmt.stderr b/tests/ui/duplicate-fmt.stderr index 3206640..532b16b 100644 --- a/tests/ui/duplicate-fmt.stderr +++ b/tests/ui/duplicate-fmt.stderr @@ -1,5 +1,5 @@ error: only one #[error(...)] attribute is allowed - --> $DIR/duplicate-fmt.rs:5:1 + --> tests/ui/duplicate-fmt.rs:5:1 | 5 | #[error("...")] | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/duplicate-struct-source.stderr b/tests/ui/duplicate-struct-source.stderr index 76fc6f5..c8de574 100644 --- a/tests/ui/duplicate-struct-source.stderr +++ b/tests/ui/duplicate-struct-source.stderr @@ -1,5 +1,5 @@ error: duplicate #[source] attribute - --> $DIR/duplicate-struct-source.rs:7:5 + --> tests/ui/duplicate-struct-source.rs:7:5 | 7 | #[source] | ^^^^^^^^^ diff --git a/tests/ui/duplicate-transparent.stderr b/tests/ui/duplicate-transparent.stderr index c963475..a830879 100644 --- a/tests/ui/duplicate-transparent.stderr +++ b/tests/ui/duplicate-transparent.stderr @@ -1,5 +1,5 @@ error: duplicate #[error(transparent)] attribute - --> $DIR/duplicate-transparent.rs:5:1 + --> tests/ui/duplicate-transparent.rs:5:1 | 5 | #[error(transparent)] | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/from-not-source.stderr b/tests/ui/from-not-source.stderr index b656c8e..9713601 100644 --- a/tests/ui/from-not-source.stderr +++ b/tests/ui/from-not-source.stderr @@ -1,5 +1,5 @@ error: #[from] is only supported on the source field, not any other field - --> $DIR/from-not-source.rs:7:5 + --> tests/ui/from-not-source.rs:7:5 | 7 | #[from] | ^^^^^^^ diff --git a/tests/ui/lifetime.stderr b/tests/ui/lifetime.stderr index 5f86fa0..8b58136 100644 --- a/tests/ui/lifetime.stderr +++ b/tests/ui/lifetime.stderr @@ -1,11 +1,11 @@ error: non-static lifetimes are not allowed in the source of an error, because std::error::Error requires the source is dyn Error + 'static - --> $DIR/lifetime.rs:6:26 + --> tests/ui/lifetime.rs:6:26 | 6 | struct Error<'a>(#[from] Inner<'a>); | ^^^^^^^^^ error: non-static lifetimes are not allowed in the source of an error, because std::error::Error requires the source is dyn Error + 'static - --> $DIR/lifetime.rs:15:17 + --> tests/ui/lifetime.rs:15:17 | 15 | Foo(#[from] Generic<&'a str>), | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/missing-fmt.stderr b/tests/ui/missing-fmt.stderr index 1d21b1b..c0be373 100644 --- a/tests/ui/missing-fmt.stderr +++ b/tests/ui/missing-fmt.stderr @@ -1,5 +1,5 @@ error: missing #[error("...")] display attribute - --> $DIR/missing-fmt.rs:7:5 + --> tests/ui/missing-fmt.rs:7:5 | 7 | B(usize), | ^^^^^^^^ diff --git a/tests/ui/no-display.stderr b/tests/ui/no-display.stderr index 8af2452..e6a52f5 100644 --- a/tests/ui/no-display.stderr +++ b/tests/ui/no-display.stderr @@ -1,12 +1,23 @@ error[E0599]: the method `as_display` exists for reference `&NoDisplay`, but its trait bounds were not satisfied - --> $DIR/no-display.rs:7:9 - | -4 | struct NoDisplay; - | ----------------- doesn't satisfy `NoDisplay: std::fmt::Display` + --> tests/ui/no-display.rs:7:9 + | +4 | struct NoDisplay; + | ----------------- doesn't satisfy `NoDisplay: std::fmt::Display` ... -7 | #[error("thread: {thread}")] - | ^^^^^^^^^^^^^^^^^^ method cannot be called on `&NoDisplay` due to unsatisfied trait bounds - | - = note: the following trait bounds were not satisfied: - `NoDisplay: std::fmt::Display` - which is required by `&NoDisplay: DisplayAsDisplay` +7 | #[error("thread: {thread}")] + | ^^^^^^^^^^^^^^^^^^ method cannot be called on `&NoDisplay` due to unsatisfied trait bounds + | + = note: the following trait bounds were not satisfied: + `NoDisplay: std::fmt::Display` + which is required by `&NoDisplay: DisplayAsDisplay` +note: the following trait must be implemented + --> $RUST/core/src/fmt/mod.rs + | + | / pub trait Display { + | | /// Formats the value using the given formatter. + | | /// + | | /// # Examples +... | + | | fn fmt(&self, f: &mut Formatter<'_>) -> Result; + | | } + | |_^ diff --git a/tests/ui/source-enum-not-error.stderr b/tests/ui/source-enum-not-error.stderr index 2bf7aea..d01cba5 100644 --- a/tests/ui/source-enum-not-error.stderr +++ b/tests/ui/source-enum-not-error.stderr @@ -1,17 +1,28 @@ error[E0599]: the method `as_dyn_error` exists for reference `&NotError`, but its trait bounds were not satisfied - --> $DIR/source-enum-not-error.rs:10:9 - | -4 | pub struct NotError; - | -------------------- - | | - | doesn't satisfy `NotError: AsDynError` - | doesn't satisfy `NotError: std::error::Error` + --> tests/ui/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 cannot be called on `&NotError` due to unsatisfied trait bounds - | - = note: 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` +10 | source: NotError, + | ^^^^^^ method cannot be called on `&NotError` due to unsatisfied trait bounds + | + = note: 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` +note: the following trait must be implemented + --> $RUST/std/src/error.rs + | + | / pub trait Error: Debug + Display { + | | /// The lower-level source of this error, if any. + | | /// + | | /// # Examples +... | + | | } + | | } + | |_^ diff --git a/tests/ui/source-struct-not-error.stderr b/tests/ui/source-struct-not-error.stderr index 7a2c0fe..be1331a 100644 --- a/tests/ui/source-struct-not-error.stderr +++ b/tests/ui/source-struct-not-error.stderr @@ -1,16 +1,27 @@ error[E0599]: the method `as_dyn_error` exists for struct `NotError`, but its trait bounds were not satisfied - --> $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` + --> tests/ui/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 cannot be called on `NotError` due to unsatisfied trait bounds - | - = note: the following trait bounds were not satisfied: - `NotError: std::error::Error` - which is required by `NotError: AsDynError` +9 | source: NotError, + | ^^^^^^ method cannot be called on `NotError` due to unsatisfied trait bounds + | + = note: the following trait bounds were not satisfied: + `NotError: std::error::Error` + which is required by `NotError: AsDynError` +note: the following trait must be implemented + --> $RUST/std/src/error.rs + | + | / pub trait Error: Debug + Display { + | | /// The lower-level source of this error, if any. + | | /// + | | /// # Examples +... | + | | } + | | } + | |_^ diff --git a/tests/ui/transparent-display.stderr b/tests/ui/transparent-display.stderr index 0148830..54d958b 100644 --- a/tests/ui/transparent-display.stderr +++ b/tests/ui/transparent-display.stderr @@ -1,5 +1,5 @@ error: cannot have both #[error(transparent)] and a display attribute - --> $DIR/transparent-display.rs:5:1 + --> tests/ui/transparent-display.rs:5:1 | 5 | #[error("...")] | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/transparent-enum-many.stderr b/tests/ui/transparent-enum-many.stderr index 0c409ef..a9adfa5 100644 --- a/tests/ui/transparent-enum-many.stderr +++ b/tests/ui/transparent-enum-many.stderr @@ -1,5 +1,5 @@ error: #[error(transparent)] requires exactly one field - --> $DIR/transparent-enum-many.rs:5:5 + --> tests/ui/transparent-enum-many.rs:5:5 | 5 | / #[error(transparent)] 6 | | Other(anyhow::Error, String), diff --git a/tests/ui/transparent-enum-source.stderr b/tests/ui/transparent-enum-source.stderr index a4e6985..ccb9067 100644 --- a/tests/ui/transparent-enum-source.stderr +++ b/tests/ui/transparent-enum-source.stderr @@ -1,5 +1,5 @@ error: transparent variant can't contain #[source] - --> $DIR/transparent-enum-source.rs:6:11 + --> tests/ui/transparent-enum-source.rs:6:11 | 6 | Other(#[source] anyhow::Error), | ^^^^^^^^^ diff --git a/tests/ui/transparent-struct-many.stderr b/tests/ui/transparent-struct-many.stderr index 102f0b3..c0e3806 100644 --- a/tests/ui/transparent-struct-many.stderr +++ b/tests/ui/transparent-struct-many.stderr @@ -1,5 +1,5 @@ error: #[error(transparent)] requires exactly one field - --> $DIR/transparent-struct-many.rs:4:1 + --> tests/ui/transparent-struct-many.rs:4:1 | 4 | #[error(transparent)] | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/transparent-struct-source.stderr b/tests/ui/transparent-struct-source.stderr index 16ea50b..3012ca3 100644 --- a/tests/ui/transparent-struct-source.stderr +++ b/tests/ui/transparent-struct-source.stderr @@ -1,5 +1,5 @@ error: transparent error struct can't contain #[source] - --> $DIR/transparent-struct-source.rs:5:18 + --> tests/ui/transparent-struct-source.rs:5:18 | 5 | pub struct Error(#[source] anyhow::Error); | ^^^^^^^^^ diff --git a/tests/ui/unexpected-field-fmt.stderr b/tests/ui/unexpected-field-fmt.stderr index 42d80db..bf3c24d 100644 --- a/tests/ui/unexpected-field-fmt.stderr +++ b/tests/ui/unexpected-field-fmt.stderr @@ -1,5 +1,5 @@ error: not expected here; the #[error(...)] attribute belongs on top of a struct or an enum variant - --> $DIR/unexpected-field-fmt.rs:6:9 + --> tests/ui/unexpected-field-fmt.rs:6:9 | 6 | #[error("...")] | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/unexpected-struct-source.stderr b/tests/ui/unexpected-struct-source.stderr index f48d554..6f15841 100644 --- a/tests/ui/unexpected-struct-source.stderr +++ b/tests/ui/unexpected-struct-source.stderr @@ -1,5 +1,5 @@ error: not expected here; the #[source] attribute belongs on a specific field - --> $DIR/unexpected-struct-source.rs:4:1 + --> tests/ui/unexpected-struct-source.rs:4:1 | 4 | #[source] | ^^^^^^^^^ diff --git a/tests/ui/union.stderr b/tests/ui/union.stderr index a378011..3ec4d71 100644 --- a/tests/ui/union.stderr +++ b/tests/ui/union.stderr @@ -1,5 +1,5 @@ error: union as errors are not supported - --> $DIR/union.rs:4:1 + --> tests/ui/union.rs:4:1 | 4 | / pub union U { 5 | | msg: &'static str, -- cgit v1.2.3 From e7af8e1cc6282e4289bb86c0d495c55ba9c70b30 Mon Sep 17 00:00:00 2001 From: David LeGare Date: Wed, 2 Mar 2022 19:54:26 +0000 Subject: Update TEST_MAPPING Test: cd external/rust/crates && atest --host -c Change-Id: I5b51b677e37c9ad38a20704460a743420aa1b09f --- TEST_MAPPING | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/TEST_MAPPING b/TEST_MAPPING index ec89789..eea7991 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -21,6 +21,21 @@ { "name": "authfs_device_test_src_lib" }, + { + "name": "diced_open_dice_cbor_test" + }, + { + "name": "diced_sample_inputs_test" + }, + { + "name": "diced_test" + }, + { + "name": "diced_utils_test" + }, + { + "name": "diced_vendor_test" + }, { "name": "doh_unit_test" }, @@ -52,10 +67,13 @@ "name": "libapkverify.test" }, { - "name": "microdroid_manager_test" + "name": "libcert_request_validator_tests" }, { - "name": "open_then_run_module" + "name": "librustutils_test" + }, + { + "name": "microdroid_manager_test" }, { "name": "virtualizationservice_device_test" @@ -71,6 +89,21 @@ { "name": "authfs_device_test_src_lib" }, + { + "name": "diced_open_dice_cbor_test" + }, + { + "name": "diced_sample_inputs_test" + }, + { + "name": "diced_test" + }, + { + "name": "diced_utils_test" + }, + { + "name": "diced_vendor_test" + }, { "name": "doh_unit_test" }, @@ -102,10 +135,13 @@ "name": "libapkverify.test" }, { - "name": "microdroid_manager_test" + "name": "libcert_request_validator_tests" }, { - "name": "open_then_run_module" + "name": "librustutils_test" + }, + { + "name": "microdroid_manager_test" }, { "name": "virtualizationservice_device_test" -- cgit v1.2.3