diff options
author | Chih-hung Hsieh <chh@google.com> | 2020-11-05 23:33:21 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-11-05 23:33:21 +0000 |
commit | 9d99ce83a49d6f716a7f2f9e33fe2998ce99ca9c (patch) | |
tree | 925237d682cab06d8d9733fab0f64f47229a6ddb | |
parent | 4d151fea1237bd19ccb57b842311ae67a14e9188 (diff) | |
parent | 653eefb1b7737ad821d4ae9dd714338aa0b5d43e (diff) | |
download | thiserror-9d99ce83a49d6f716a7f2f9e33fe2998ce99ca9c.tar.gz |
Merge "Upgrade rust/crates/thiserror to 1.0.22" am: 653eefb1b7
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/thiserror/+/1487859
Change-Id: I920b96a2bebbe4affa68b94a240e65efdc182347
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 2 | ||||
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | Cargo.toml.orig | 4 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rw-r--r-- | tests/test_display.rs | 42 | ||||
-rw-r--r-- | tests/ui/concat-display.rs | 15 | ||||
-rw-r--r-- | tests/ui/concat-display.stderr | 10 |
8 files changed, 77 insertions, 10 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index a0bee43..660ea81 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "f757a0489b2cddfea15ab870b49f159ce1aa71cd" + "sha1": "09f247addaf6c5f57353f9558ba131e6619390c7" } } @@ -13,5 +13,5 @@ rust_library { // proc-macro2-1.0.24 "default,proc-macro" // quote-1.0.7 "default,proc-macro" // syn-1.0.48 "clone-impls,default,derive,parsing,printing,proc-macro,quote,visit" -// thiserror-impl-1.0.21 +// thiserror-impl-1.0.22 // unicode-xid-0.2.1 "default" @@ -13,7 +13,7 @@ [package] edition = "2018" name = "thiserror" -version = "1.0.21" +version = "1.0.22" 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.21" +version = "=1.0.22" [dev-dependencies.anyhow] version = "1.0" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index ff7294d..101d6b0 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "thiserror" -version = "1.0.21" +version = "1.0.22" 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.21", path = "impl" } +thiserror-impl = { version = "=1.0.22", 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.21.crate" + value: "https://static.crates.io/crates/thiserror/thiserror-1.0.22.crate" } - version: "1.0.21" + version: "1.0.22" license_type: NOTICE last_upgrade_date { year: 2020 - month: 10 - day: 26 + month: 11 + day: 4 } } diff --git a/tests/test_display.rs b/tests/test_display.rs index 9bc385a..949d9ed 100644 --- a/tests/test_display.rs +++ b/tests/test_display.rs @@ -230,3 +230,45 @@ fn test_macro_rules() { assert("0", Error0::Repro(0)); assert("0", Error1::Repro(0)); } + +#[test] +fn test_raw() { + #[derive(Error, Debug)] + #[error("braced raw error: {r#fn}")] + struct Error { + r#fn: &'static str, + } + + assert("braced raw error: T", Error { r#fn: "T" }); +} + +#[test] +fn test_raw_enum() { + #[derive(Error, Debug)] + enum Error { + #[error("braced raw error: {r#fn}")] + Braced { r#fn: &'static str }, + } + + assert("braced raw error: T", Error::Braced { r#fn: "T" }); +} + +#[test] +fn test_raw_conflict() { + #[derive(Error, Debug)] + enum Error { + #[error("braced raw error: {r#func}, {func}", func = "U")] + Braced { r#func: &'static str }, + } + + assert("braced raw error: T, U", Error::Braced { r#func: "T" }); +} + +#[test] +fn test_keyword() { + #[derive(Error, Debug)] + #[error("error: {type}", type = 1)] + struct Error; + + assert("error: 1", Error); +} diff --git a/tests/ui/concat-display.rs b/tests/ui/concat-display.rs new file mode 100644 index 0000000..8b53cc0 --- /dev/null +++ b/tests/ui/concat-display.rs @@ -0,0 +1,15 @@ +use thiserror::Error; + +macro_rules! error_type { + ($name:ident, $what:expr) => { + // Use #[error("invalid {}", $what)] instead. + + #[derive(Error, Debug)] + #[error(concat!("invalid ", $what))] + pub struct $name; + }; +} + +error_type!(Error, "foo"); + +fn main() {} diff --git a/tests/ui/concat-display.stderr b/tests/ui/concat-display.stderr new file mode 100644 index 0000000..df1e19a --- /dev/null +++ b/tests/ui/concat-display.stderr @@ -0,0 +1,10 @@ +error: expected string literal + --> $DIR/concat-display.rs:8:17 + | +8 | #[error(concat!("invalid ", $what))] + | ^^^^^^ +... +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) |