diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:11:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:11:28 +0000 |
commit | 94a0819fe3a0d679c3042a77bfe6a2afc505daea (patch) | |
tree | 2b827afe6a05f3538db3f7803a88c4587fe85648 /vendor/thiserror | |
parent | Adding upstream version 1.64.0+dfsg1. (diff) | |
download | rustc-94a0819fe3a0d679c3042a77bfe6a2afc505daea.tar.xz rustc-94a0819fe3a0d679c3042a77bfe6a2afc505daea.zip |
Adding upstream version 1.66.0+dfsg1.upstream/1.66.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
31 files changed, 387 insertions, 156 deletions
diff --git a/vendor/thiserror-impl/.cargo-checksum.json b/vendor/thiserror-impl/.cargo-checksum.json index a1c0ef900..e398ffbb5 100644 --- a/vendor/thiserror-impl/.cargo-checksum.json +++ b/vendor/thiserror-impl/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"4089f6b56d562de455fa1c98d3122512e8289085508d055366059f00f14060e9","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","src/ast.rs":"c7601e8394f5ee304365c520181f0dbeaa807ddaa71ce4a8618ea1a70f81b3b2","src/attr.rs":"d1fe75dde04cb8df6da4e1aaec5b38c2b0f634fa3432877993b3fec4cc08b6b5","src/expand.rs":"cf6b969e8ecaaf3a6b31ffebce395e1882a9f263985970041c6e687f0ce5a6cd","src/fmt.rs":"d63d39120c18712596f9f2a1715821148c2becd4d8bad5bc1b307210a84dbe98","src/generics.rs":"ac493703c9955400d4fab22cbbdbbc4bf4f6f72c112b34be8b784142142ff74f","src/lib.rs":"57dce312458895d25c6fd0ef3111362b053edd2f5e0ee04d19edb33bd3c1afbd","src/prop.rs":"6709932aee8f9d217f40cd644629c0ecb2f46d333ae8a1398e8d745534f4e028","src/valid.rs":"93317a8342891dc4569cfdd5f64a8c64cdec8fff49911428427b0621974eec32"},"package":"aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b"}
\ No newline at end of file +{"files":{"Cargo.toml":"af63bbe7a8ec50e29f44aa648a65afd05486852589b467030d28bbd7e0c878f4","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","src/ast.rs":"c7601e8394f5ee304365c520181f0dbeaa807ddaa71ce4a8618ea1a70f81b3b2","src/attr.rs":"d1fe75dde04cb8df6da4e1aaec5b38c2b0f634fa3432877993b3fec4cc08b6b5","src/expand.rs":"8e2bc7ca24e8f8d9b179b792e772d3699154b750a08dcb942be298b7cc032563","src/fmt.rs":"d63d39120c18712596f9f2a1715821148c2becd4d8bad5bc1b307210a84dbe98","src/generics.rs":"2076cde22271be355a8131a77add4b93f83ab0af4317cd2df5471fffa4f95c66","src/lib.rs":"7d023310cd3db670554ce108a6afd94e1ae3c55c83661d4b9fcebdf1865b9e4b","src/prop.rs":"6709932aee8f9d217f40cd644629c0ecb2f46d333ae8a1398e8d745534f4e028","src/valid.rs":"ac95253944fd360d3578d0643a7baabb2cfa6bf9fbced7a6ce1f7b0529a3bb98"},"package":"982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb"}
\ No newline at end of file diff --git a/vendor/thiserror-impl/Cargo.toml b/vendor/thiserror-impl/Cargo.toml index 97e0042c1..9f832394e 100644 --- a/vendor/thiserror-impl/Cargo.toml +++ b/vendor/thiserror-impl/Cargo.toml @@ -13,16 +13,18 @@ edition = "2018" rust-version = "1.31" name = "thiserror-impl" -version = "1.0.30" +version = "1.0.37" authors = ["David Tolnay <dtolnay@gmail.com>"] description = "Implementation detail of the `thiserror` crate" license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/thiserror" + [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] [lib] proc-macro = true + [dependencies.proc-macro2] version = "1.0" diff --git a/vendor/thiserror-impl/src/expand.rs b/vendor/thiserror-impl/src/expand.rs index 435ad4847..43522096a 100644 --- a/vendor/thiserror-impl/src/expand.rs +++ b/vendor/thiserror-impl/src/expand.rs @@ -53,51 +53,59 @@ fn impl_struct(input: Struct) -> TokenStream { let source_method = source_body.map(|body| { quote! { fn source(&self) -> std::option::Option<&(dyn std::error::Error + 'static)> { - use thiserror::private::AsDynError; + use thiserror::__private::AsDynError; #body } } }); - let backtrace_method = input.backtrace_field().map(|backtrace_field| { + let provide_method = input.backtrace_field().map(|backtrace_field| { + let demand = quote!(demand); let backtrace = &backtrace_field.member; let body = if let Some(source_field) = input.source_field() { let source = &source_field.member; - let source_backtrace = if type_is_option(source_field.ty) { + let source_provide = if type_is_option(source_field.ty) { quote_spanned! {source.span()=> - self.#source.as_ref().and_then(|source| source.as_dyn_error().backtrace()) + if let std::option::Option::Some(source) = &self.#source { + source.thiserror_provide(#demand); + } } } else { quote_spanned! {source.span()=> - self.#source.as_dyn_error().backtrace() + self.#source.thiserror_provide(#demand); } }; - let combinator = if source == backtrace { - source_backtrace + let self_provide = if source == backtrace { + None } else if type_is_option(backtrace_field.ty) { - quote! { - #source_backtrace.or(self.#backtrace.as_ref()) - } + Some(quote! { + if let std::option::Option::Some(backtrace) = &self.#backtrace { + #demand.provide_ref::<std::backtrace::Backtrace>(backtrace); + } + }) } else { - quote! { - std::option::Option::Some(#source_backtrace.unwrap_or(&self.#backtrace)) - } + Some(quote! { + #demand.provide_ref::<std::backtrace::Backtrace>(&self.#backtrace); + }) }; quote! { - use thiserror::private::AsDynError; - #combinator + use thiserror::__private::ThiserrorProvide; + #source_provide + #self_provide } } else if type_is_option(backtrace_field.ty) { quote! { - self.#backtrace.as_ref() + if let std::option::Option::Some(backtrace) = &self.#backtrace { + #demand.provide_ref::<std::backtrace::Backtrace>(backtrace); + } } } else { quote! { - std::option::Option::Some(&self.#backtrace) + #demand.provide_ref::<std::backtrace::Backtrace>(&self.#backtrace); } }; quote! { - fn backtrace(&self) -> std::option::Option<&std::backtrace::Backtrace> { + fn provide<'_demand>(&'_demand self, #demand: &mut std::any::Demand<'_demand>) { #body } } @@ -115,7 +123,7 @@ fn impl_struct(input: Struct) -> TokenStream { let use_as_display = if display.has_bonus_display { Some(quote! { #[allow(unused_imports)] - use thiserror::private::{DisplayAsDisplay, PathAsDisplay}; + use thiserror::__private::{DisplayAsDisplay, PathAsDisplay}; }) } else { None @@ -177,7 +185,7 @@ fn impl_struct(input: Struct) -> TokenStream { #[allow(unused_qualifications)] impl #impl_generics #error_trait for #ty #ty_generics #error_where_clause { #source_method - #backtrace_method + #provide_method } #display_impl #from_impl @@ -226,7 +234,7 @@ fn impl_enum(input: Enum) -> TokenStream { }); Some(quote! { fn source(&self) -> std::option::Option<&(dyn std::error::Error + 'static)> { - use thiserror::private::AsDynError; + use thiserror::__private::AsDynError; #[allow(deprecated)] match self { #(#arms)* @@ -237,7 +245,8 @@ fn impl_enum(input: Enum) -> TokenStream { None }; - let backtrace_method = if input.has_backtrace() { + let provide_method = if input.has_backtrace() { + let demand = quote!(demand); let arms = input.variants.iter().map(|variant| { let ident = &variant.ident; match (variant.backtrace_field(), variant.source_field()) { @@ -247,22 +256,26 @@ fn impl_enum(input: Enum) -> TokenStream { let backtrace = &backtrace_field.member; let source = &source_field.member; let varsource = quote!(source); - let source_backtrace = if type_is_option(source_field.ty) { + let source_provide = if type_is_option(source_field.ty) { quote_spanned! {source.span()=> - #varsource.as_ref().and_then(|source| source.as_dyn_error().backtrace()) + if let std::option::Option::Some(source) = #varsource { + source.thiserror_provide(#demand); + } } } else { quote_spanned! {source.span()=> - #varsource.as_dyn_error().backtrace() + #varsource.thiserror_provide(#demand); } }; - let combinator = if type_is_option(backtrace_field.ty) { + let self_provide = if type_is_option(backtrace_field.ty) { quote! { - #source_backtrace.or(backtrace.as_ref()) + if let std::option::Option::Some(backtrace) = backtrace { + #demand.provide_ref::<std::backtrace::Backtrace>(backtrace); + } } } else { quote! { - std::option::Option::Some(#source_backtrace.unwrap_or(backtrace)) + #demand.provide_ref::<std::backtrace::Backtrace>(backtrace); } }; quote! { @@ -271,8 +284,9 @@ fn impl_enum(input: Enum) -> TokenStream { #source: #varsource, .. } => { - use thiserror::private::AsDynError; - #combinator + use thiserror::__private::ThiserrorProvide; + #source_provide + #self_provide } } } @@ -281,40 +295,50 @@ fn impl_enum(input: Enum) -> TokenStream { { let backtrace = &backtrace_field.member; let varsource = quote!(source); - let source_backtrace = if type_is_option(source_field.ty) { + let source_provide = if type_is_option(source_field.ty) { quote_spanned! {backtrace.span()=> - #varsource.as_ref().and_then(|source| source.as_dyn_error().backtrace()) + if let std::option::Option::Some(source) = #varsource { + source.thiserror_provide(#demand); + } } } else { quote_spanned! {backtrace.span()=> - #varsource.as_dyn_error().backtrace() + #varsource.thiserror_provide(#demand); } }; quote! { #ty::#ident {#backtrace: #varsource, ..} => { - use thiserror::private::AsDynError; - #source_backtrace + use thiserror::__private::ThiserrorProvide; + #source_provide } } } (Some(backtrace_field), _) => { let backtrace = &backtrace_field.member; let body = if type_is_option(backtrace_field.ty) { - quote!(backtrace.as_ref()) + quote! { + if let std::option::Option::Some(backtrace) = backtrace { + #demand.provide_ref::<std::backtrace::Backtrace>(backtrace); + } + } } else { - quote!(std::option::Option::Some(backtrace)) + quote! { + #demand.provide_ref::<std::backtrace::Backtrace>(backtrace); + } }; quote! { - #ty::#ident {#backtrace: backtrace, ..} => #body, + #ty::#ident {#backtrace: backtrace, ..} => { + #body + } } } (None, _) => quote! { - #ty::#ident {..} => std::option::Option::None, + #ty::#ident {..} => {} }, } }); Some(quote! { - fn backtrace(&self) -> std::option::Option<&std::backtrace::Backtrace> { + fn provide<'_demand>(&'_demand self, #demand: &mut std::any::Demand<'_demand>) { #[allow(deprecated)] match self { #(#arms)* @@ -335,7 +359,7 @@ fn impl_enum(input: Enum) -> TokenStream { }) { Some(quote! { #[allow(unused_imports)] - use thiserror::private::{DisplayAsDisplay, PathAsDisplay}; + use thiserror::__private::{DisplayAsDisplay, PathAsDisplay}; }) } else { None @@ -420,7 +444,7 @@ fn impl_enum(input: Enum) -> TokenStream { #[allow(unused_qualifications)] impl #impl_generics #error_trait for #ty #ty_generics #error_where_clause { #source_method - #backtrace_method + #provide_method } #display_impl #(#from_impls)* diff --git a/vendor/thiserror-impl/src/generics.rs b/vendor/thiserror-impl/src/generics.rs index 254c2ed35..95592a737 100644 --- a/vendor/thiserror-impl/src/generics.rs +++ b/vendor/thiserror-impl/src/generics.rs @@ -57,6 +57,7 @@ impl InferredBounds { } } + #[allow(clippy::type_repetition_in_bounds, clippy::trait_duplication_in_bounds)] // clippy bug: https://github.com/rust-lang/rust-clippy/issues/8771 pub fn insert(&mut self, ty: impl ToTokens, bound: impl ToTokens) { let ty = ty.to_token_stream(); let bound = bound.to_token_stream(); diff --git a/vendor/thiserror-impl/src/lib.rs b/vendor/thiserror-impl/src/lib.rs index a4d5ae7d5..f0fc96917 100644 --- a/vendor/thiserror-impl/src/lib.rs +++ b/vendor/thiserror-impl/src/lib.rs @@ -1,13 +1,16 @@ #![allow( clippy::blocks_in_if_conditions, + clippy::cast_lossless, clippy::cast_possible_truncation, + clippy::manual_find, clippy::manual_map, clippy::map_unwrap_or, clippy::needless_pass_by_value, clippy::option_if_let_else, clippy::range_plus_one, clippy::single_match_else, - clippy::too_many_lines + clippy::too_many_lines, + clippy::wrong_self_convention )] extern crate proc_macro; diff --git a/vendor/thiserror-impl/src/valid.rs b/vendor/thiserror-impl/src/valid.rs index 7657265ef..cf5b8592c 100644 --- a/vendor/thiserror-impl/src/valid.rs +++ b/vendor/thiserror-impl/src/valid.rs @@ -180,7 +180,11 @@ fn check_field_attrs(fields: &[Field]) -> Result<()> { } } if let Some(from_field) = from_field { - if fields.len() > 1 + has_backtrace as usize { + let max_expected_fields = match backtrace_field { + Some(backtrace_field) => 1 + !same_member(from_field, backtrace_field) as usize, + None => 1 + has_backtrace as usize, + }; + if fields.len() > max_expected_fields { return Err(Error::new_spanned( from_field.attrs.from, "deriving From requires no fields other than source and backtrace", diff --git a/vendor/thiserror/.cargo-checksum.json b/vendor/thiserror/.cargo-checksum.json index 0b30f4e65..b82148e8f 100644 --- a/vendor/thiserror/.cargo-checksum.json +++ b/vendor/thiserror/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"4e67c7ab97838c17f0db6b027bbddfb59f549bf5b965f2e9e11863c522d6a80a","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"a9f0f8261b1cb4b7a5e6e32242f511339e74452e44a92b6e6158c665108acb9f","rust-toolchain.toml":"6bbb61302978c736b2da03e4fb40e3beab908f85d533ab46fd541e637b5f3e0f","src/aserror.rs":"3dd14cfcfe4a0ab8b1dd774e4ea0a0197989afe84e0687e73873b61cfa4347fa","src/display.rs":"63c492bfa8b8e9180ad5abcbe63c1173b4ad490c47ec33cac9a338f96c8f8e42","src/lib.rs":"7e740a989ed7fe4f851a0a3ea3143b655a907a81a755034a84171466ab44f94b","tests/compiletest.rs":"c61425723ca4eeb4a9079495c0e9640a9d210780b47e183fdb09ee2ad6887ce6","tests/test_backtrace.rs":"32175af055514c4d8ee20923bdf26bf64b060e8642d8be3c50b77187d81c3acf","tests/test_display.rs":"dde5540dd4b47613ae9e3a1360ced832131a86c83ccc7da2bb89042062aa5d5e","tests/test_error.rs":"994f35bba245cbdc08c094094b9c1440a0a2b48333663c73c6a96e772ae5d3d8","tests/test_expr.rs":"cd42633c0b0a0f595a5c498e576ca50b3a1c555c54b4652bdd296a4073771a61","tests/test_from.rs":"41f2fbc391d95be68aefea3e4ae59bb71074bb020b0a1e109acbdea1f45e7666","tests/test_generics.rs":"4ca6a1a47bfc0095783133b7db9f626d176f65ca077cc15847f6ef5caff2d881","tests/test_lints.rs":"c17d79d77edfcdd4b8f6dcdcd1c70ad065cfbc747e1a618ac6343315d0b59ea4","tests/test_option.rs":"a3510dc1aef5a2dc995188506a560d7597d38717408606dece0b50a30d39bc26","tests/test_path.rs":"8f25b9be8940b9c41b254ae1bd265851e593734488fb0dbf94444bb583b95944","tests/test_source.rs":"6c352c520ead863601043f9c4a23751e235e710790f5c11f56f817a8811eb94f","tests/test_transparent.rs":"410a1328202e70bf64301737d4dda700bd9f073faacd3e50bdc4a7ddeddc8aa1","tests/ui/bad-field-attr.rs":"c5b567e3091969a01061843fb2d95c5e1aa3fa81edfeecdf416a84a6fba40aa8","tests/ui/bad-field-attr.stderr":"78f576d5ec66464a77f1cdf0f5bb7dcdf18f7f04f1165983a6239ec59d908ea3","tests/ui/concat-display.rs":"3995bd6b3bdd67df7bb16499775d89600c0dd20895633fe807396a64c117078d","tests/ui/concat-display.stderr":"f8ee9f2003def1b60b482e0fe01a61a2b77fd82508454a843dc6df60b8c92051","tests/ui/duplicate-enum-source.rs":"bfe28ce18042d446a76c7411aa233598211ce1157fdd3cb87bff3b3fa7c33131","tests/ui/duplicate-enum-source.stderr":"3d32fead420b27b4497be49080bc3b78f7f0ba339ead3de6c94e5dc20302c18f","tests/ui/duplicate-fmt.rs":"af53b66445bcce076a114376747f176b42c060a156563a41ccb638ae14c451fd","tests/ui/duplicate-fmt.stderr":"998bb121ce6f1595fd99529a7a1b06451b6bf476924337dce5524a83a7a5f1a1","tests/ui/duplicate-struct-source.rs":"f3d5f8e3d6fccfcdbb630db291353709583a920c6bf46f9f9de9966b67ea4c0f","tests/ui/duplicate-struct-source.stderr":"fb761d76668ac42357cf37b03c0abdbae5de0a828034990850291c9cb6ab766d","tests/ui/duplicate-transparent.rs":"41a9447e85f1a47027023442acde55c3d8610ec46d91b39bd43a42d7a004d747","tests/ui/duplicate-transparent.stderr":"4975abad43e973df158f18098d9bcb9dc39f8e75d3e733ed5d6620d1ee065c11","tests/ui/from-not-source.rs":"744a55aeffe11066830159ac023c33aaa5576e313b341fa24440ee13dfe3ac98","tests/ui/from-not-source.stderr":"525038e8b841707b927434cca4549168f73bd305faca17552a0d1fffa542ccc4","tests/ui/lifetime.rs":"e72e0391695e47fcd07edbf3819f114e468e2097086ec687781c7c8d6b4b7da7","tests/ui/lifetime.stderr":"d889a23f71324afe95dafc5f9d15337fbdbc9977cb8924f0cafe3a3becf4ced7","tests/ui/missing-fmt.rs":"bc9e2830e54c2474ff6c27a766ed3dee88d29e40f93f30e8d64d63233866c17d","tests/ui/missing-fmt.stderr":"9a20ccee9b660fe31a5b3199307b48580bb8305cb9ce33d97d3fc767a0cfc614","tests/ui/no-display.rs":"962245372272d23e9833311c15e73221b3c7da822a2ff90189613af56ffb5c2e","tests/ui/no-display.stderr":"d1d9e24b4689cd09e784ab9b62721f77a6fa5f4372ba45300997d2569ff7aa9a","tests/ui/source-enum-not-error.rs":"7c57c63b3ec37bc456738acea2e1038de5b0f32fe7e83984037d7ad1ed921737","tests/ui/source-enum-not-error.stderr":"897d610f1114bd108fa607f038f93438d57a1cc711db26ccb4e20ef31248386a","tests/ui/source-struct-not-error.rs":"09fb7713637242dca9192585a6daeb8d732dc1c1d0fa522b74f1c98618e6d949","tests/ui/source-struct-not-error.stderr":"a310d33021a1a1ed0a61090e7d60236a3c4da478a14ae7635c124779348ce831","tests/ui/transparent-display.rs":"b3c59583eb64b0b5a246444456d03cf52d51bcdc08885023600dbb44fd87e5f2","tests/ui/transparent-display.stderr":"16d538914e0d92026bde4b4bec75660217da9ecc6b621d12d2eb81d33ed1d1da","tests/ui/transparent-enum-many.rs":"2a40a764fb4683bff57973eec61507a6c00f7d4d7a32da6e7bd0190c2e445434","tests/ui/transparent-enum-many.stderr":"f1d78c1d6d8edbef153420db4fb9ca3dc6076fa043b5b1bc0cd291daa417a3ea","tests/ui/transparent-enum-source.rs":"18f606a98ac0a53f08dc56f5f923b9cbe75d25ed34479c777b48dac305d5968c","tests/ui/transparent-enum-source.stderr":"1b2e0ac53951034575d43ec0396c4e2b3cfb272db2aef8d6baa13a7e1632cc84","tests/ui/transparent-struct-many.rs":"72c6b6c1a44c203d3bc68989b2f1ec092531ef75b745432824c3776c290326f6","tests/ui/transparent-struct-many.stderr":"7bd0536dbb54a0ce7d4a8e66ca7624a1b132d8a1d1e4fecca642ec77494ac01c","tests/ui/transparent-struct-source.rs":"863fa691ed7d27e8767da58d9ee11fd40d6642274b36338ca1074c07964ea2b3","tests/ui/transparent-struct-source.stderr":"267dab65929e67d32347fb467a00b43af931f8205d727d7671938580217fc70e","tests/ui/unexpected-field-fmt.rs":"29fba7b4d81c642ec8e47cfe053aa515acf9080a86d65e685363a48993becfe3","tests/ui/unexpected-field-fmt.stderr":"20731c4a08af04bed3ff513903adadd690b6bc532b15604557e7f25575a8338f","tests/ui/unexpected-struct-source.rs":"c6cbe882d622635c216feb8290b1bd536ce0ec4feee16bc087667a21b3641d5c","tests/ui/unexpected-struct-source.stderr":"7c8227513478f6cc09e8a28be337c8a0e758a06ca5978d774c91bd43c4a54043","tests/ui/union.rs":"331adff27cebd8b95b03b6742cc8247331fda1f961e1590ed39c8d39f50cf1d8","tests/ui/union.stderr":"5f67ad29753d6fb14bc03aef7d4a1f660ee7796e469c037efbf8b13456934ad3"},"package":"854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417"}
\ No newline at end of file +{"files":{"Cargo.toml":"1d01528e44c86dd86ee07557c6cd89bd3cf37a2456e6f3430af299d84f304035","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"959ac4d4dc43ce39235613d853db8df4a0cfd79e262fc38aba43a98331643952","build.rs":"8b8d9cbf84b9a2fd108b49ecb4bae327da688d80b818acda9ee17170c788e193","rust-toolchain.toml":"6bbb61302978c736b2da03e4fb40e3beab908f85d533ab46fd541e637b5f3e0f","src/aserror.rs":"c93bd9191f26a7599043b397e26822564d9bafaa339a19861182a9909e8a3811","src/display.rs":"63c492bfa8b8e9180ad5abcbe63c1173b4ad490c47ec33cac9a338f96c8f8e42","src/lib.rs":"3fcc3c1ab31a64215978b92e68c1421ec8c5fcb942e57eb35adb9cc07a865730","src/provide.rs":"b2f7a33f44f44a03e94f54cc4b79ba2dcc5fcf0fdf64b07cdd9588a6544c8d8e","tests/compiletest.rs":"022a8e400ef813d7ea1875b944549cee5125f6a995dc33e93b48cba3e1b57bd1","tests/test_backtrace.rs":"fd1f326bc23e6c1611a51bc43c1d5092b32ee18a1613abe20da0818e5729c0ed","tests/test_deprecated.rs":"7b80a10f090a3982da017556d3d71398abcead59afd8278c7b9d9b1f7b66c7b3","tests/test_display.rs":"20fdc8903f06da3a698ef4377cccca26a71138ca6de67310c5bdb8a9fcb39d83","tests/test_error.rs":"d06dca3c38f22d7ce4e27dadd6c0f78e5cefe3a2ebbc5fe44abc9ddd5ee1985f","tests/test_expr.rs":"388402702a3be4ffcd0574d66733e8932bf7d5de37544a00ecb0e4f8d8246da4","tests/test_from.rs":"de1347e62069f826d8616b9e45ce6cccc3a8a8049cb51bd22d6763efe6118b0c","tests/test_generics.rs":"4f33747e3f62550d5af94687679af230ef92fbb3247ae4b41df46792a040e4dc","tests/test_lints.rs":"c17d79d77edfcdd4b8f6dcdcd1c70ad065cfbc747e1a618ac6343315d0b59ea4","tests/test_option.rs":"3a82af1ad206444b9955e3f2fda508d70f887ad0b7f7986bafc17496f63b07ab","tests/test_path.rs":"ef5452c7e828a0179f5ace7e19f95b9762aa887caf10244adbfe36ded712c090","tests/test_source.rs":"f2f04f11bf8a709eddb1c68f113cda0c2be87e56800d6b9d991bedd545b4642f","tests/test_transparent.rs":"cd8d5be14d00d610a1782104bea6c013618501dab5c3625178ecfcf66e31f939","tests/ui/bad-field-attr.rs":"c5b567e3091969a01061843fb2d95c5e1aa3fa81edfeecdf416a84a6fba40aa8","tests/ui/bad-field-attr.stderr":"78f576d5ec66464a77f1cdf0f5bb7dcdf18f7f04f1165983a6239ec59d908ea3","tests/ui/concat-display.rs":"3995bd6b3bdd67df7bb16499775d89600c0dd20895633fe807396a64c117078d","tests/ui/concat-display.stderr":"256dfde61ee689ebe51588b135e2e030bdf95ba5adef1cb59f588c797bbdeef2","tests/ui/duplicate-enum-source.rs":"bfe28ce18042d446a76c7411aa233598211ce1157fdd3cb87bff3b3fa7c33131","tests/ui/duplicate-enum-source.stderr":"3d32fead420b27b4497be49080bc3b78f7f0ba339ead3de6c94e5dc20302c18f","tests/ui/duplicate-fmt.rs":"af53b66445bcce076a114376747f176b42c060a156563a41ccb638ae14c451fd","tests/ui/duplicate-fmt.stderr":"998bb121ce6f1595fd99529a7a1b06451b6bf476924337dce5524a83a7a5f1a1","tests/ui/duplicate-struct-source.rs":"f3d5f8e3d6fccfcdbb630db291353709583a920c6bf46f9f9de9966b67ea4c0f","tests/ui/duplicate-struct-source.stderr":"fb761d76668ac42357cf37b03c0abdbae5de0a828034990850291c9cb6ab766d","tests/ui/duplicate-transparent.rs":"41a9447e85f1a47027023442acde55c3d8610ec46d91b39bd43a42d7a004d747","tests/ui/duplicate-transparent.stderr":"4975abad43e973df158f18098d9bcb9dc39f8e75d3e733ed5d6620d1ee065c11","tests/ui/from-backtrace-backtrace.rs":"1fd51c5a1f7f6b6ee676d9fc798b6276ef2ce75def33d07f0e4b7bbde3291859","tests/ui/from-backtrace-backtrace.stderr":"f9774e9dad51374501ef4a55fa2dacece4d1c70e29ca18761394bdb80a9a74da","tests/ui/from-not-source.rs":"744a55aeffe11066830159ac023c33aaa5576e313b341fa24440ee13dfe3ac98","tests/ui/from-not-source.stderr":"525038e8b841707b927434cca4549168f73bd305faca17552a0d1fffa542ccc4","tests/ui/lifetime.rs":"e72e0391695e47fcd07edbf3819f114e468e2097086ec687781c7c8d6b4b7da7","tests/ui/lifetime.stderr":"d889a23f71324afe95dafc5f9d15337fbdbc9977cb8924f0cafe3a3becf4ced7","tests/ui/missing-fmt.rs":"bc9e2830e54c2474ff6c27a766ed3dee88d29e40f93f30e8d64d63233866c17d","tests/ui/missing-fmt.stderr":"9a20ccee9b660fe31a5b3199307b48580bb8305cb9ce33d97d3fc767a0cfc614","tests/ui/no-display.rs":"962245372272d23e9833311c15e73221b3c7da822a2ff90189613af56ffb5c2e","tests/ui/no-display.stderr":"40f47b286b770808a7dc5ec7970bc5cd501c9400f2e50049cf3258174929a9c1","tests/ui/source-enum-not-error.rs":"7c57c63b3ec37bc456738acea2e1038de5b0f32fe7e83984037d7ad1ed921737","tests/ui/source-enum-not-error.stderr":"1bb601243ff11d5de08c70edf3fd89d52b4a89fcd2a5c7775d1bc11d056ced1e","tests/ui/source-struct-not-error.rs":"09fb7713637242dca9192585a6daeb8d732dc1c1d0fa522b74f1c98618e6d949","tests/ui/source-struct-not-error.stderr":"9a1a04d606309c82eea59d1745c833189f0b4f237f0741a17dd62c11ce16642d","tests/ui/transparent-display.rs":"b3c59583eb64b0b5a246444456d03cf52d51bcdc08885023600dbb44fd87e5f2","tests/ui/transparent-display.stderr":"16d538914e0d92026bde4b4bec75660217da9ecc6b621d12d2eb81d33ed1d1da","tests/ui/transparent-enum-many.rs":"2a40a764fb4683bff57973eec61507a6c00f7d4d7a32da6e7bd0190c2e445434","tests/ui/transparent-enum-many.stderr":"f1d78c1d6d8edbef153420db4fb9ca3dc6076fa043b5b1bc0cd291daa417a3ea","tests/ui/transparent-enum-source.rs":"18f606a98ac0a53f08dc56f5f923b9cbe75d25ed34479c777b48dac305d5968c","tests/ui/transparent-enum-source.stderr":"1b2e0ac53951034575d43ec0396c4e2b3cfb272db2aef8d6baa13a7e1632cc84","tests/ui/transparent-struct-many.rs":"72c6b6c1a44c203d3bc68989b2f1ec092531ef75b745432824c3776c290326f6","tests/ui/transparent-struct-many.stderr":"7bd0536dbb54a0ce7d4a8e66ca7624a1b132d8a1d1e4fecca642ec77494ac01c","tests/ui/transparent-struct-source.rs":"863fa691ed7d27e8767da58d9ee11fd40d6642274b36338ca1074c07964ea2b3","tests/ui/transparent-struct-source.stderr":"267dab65929e67d32347fb467a00b43af931f8205d727d7671938580217fc70e","tests/ui/unexpected-field-fmt.rs":"29fba7b4d81c642ec8e47cfe053aa515acf9080a86d65e685363a48993becfe3","tests/ui/unexpected-field-fmt.stderr":"20731c4a08af04bed3ff513903adadd690b6bc532b15604557e7f25575a8338f","tests/ui/unexpected-struct-source.rs":"c6cbe882d622635c216feb8290b1bd536ce0ec4feee16bc087667a21b3641d5c","tests/ui/unexpected-struct-source.stderr":"7c8227513478f6cc09e8a28be337c8a0e758a06ca5978d774c91bd43c4a54043","tests/ui/union.rs":"331adff27cebd8b95b03b6742cc8247331fda1f961e1590ed39c8d39f50cf1d8","tests/ui/union.stderr":"5f67ad29753d6fb14bc03aef7d4a1f660ee7796e469c037efbf8b13456934ad3"},"package":"10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e"}
\ No newline at end of file diff --git a/vendor/thiserror/Cargo.toml b/vendor/thiserror/Cargo.toml index 78c99d623..2f060d6d8 100644 --- a/vendor/thiserror/Cargo.toml +++ b/vendor/thiserror/Cargo.toml @@ -13,20 +13,28 @@ edition = "2018" rust-version = "1.31" name = "thiserror" -version = "1.0.30" +version = "1.0.37" authors = ["David Tolnay <dtolnay@gmail.com>"] description = "derive(Error)" documentation = "https://docs.rs/thiserror" readme = "README.md" +keywords = [ + "error", + "error-handling", + "derive", +] categories = ["rust-patterns"] license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/thiserror" + [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] + [dependencies.thiserror-impl] -version = "=1.0.30" +version = "=1.0.37" + [dev-dependencies.anyhow] -version = "1.0" +version = "1.0.65" [dev-dependencies.ref-cast] version = "1.0" diff --git a/vendor/thiserror/README.md b/vendor/thiserror/README.md index e12b693ef..8f6b896de 100644 --- a/vendor/thiserror/README.md +++ b/vendor/thiserror/README.md @@ -3,7 +3,7 @@ derive(Error) [<img alt="github" src="https://img.shields.io/badge/github-dtolnay/thiserror-8da0cb?style=for-the-badge&labelColor=555555&logo=github" height="20">](https://github.com/dtolnay/thiserror) [<img alt="crates.io" src="https://img.shields.io/crates/v/thiserror.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/thiserror) -[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-thiserror-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K" height="20">](https://docs.rs/thiserror) +[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-thiserror-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs" height="20">](https://docs.rs/thiserror) [<img alt="build status" src="https://img.shields.io/github/workflow/status/dtolnay/thiserror/CI/master?style=for-the-badge" height="20">](https://github.com/dtolnay/thiserror/actions?query=branch%3Amaster) This library provides a convenient derive macro for the standard library's @@ -124,8 +124,8 @@ pub enum DataStoreError { } ``` -- The Error trait's `backtrace()` method is implemented to return whichever - field has a type named `Backtrace`, if any. +- The Error trait's `provide()` method is implemented to provide whichever field + has a type named `Backtrace`, if any, as a `std::backtrace::Backtrace`. ```rust use std::backtrace::Backtrace; @@ -138,8 +138,9 @@ 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. + attribute) *and* is marked `#[backtrace]`, then the Error trait's `provide()` + method is forwarded to the source's `provide` so that both layers of the error + share the same backtrace. ```rust #[derive(Error, Debug)] @@ -165,6 +166,27 @@ pub enum DataStoreError { } ``` + Another use case is hiding implementation details of an error representation + behind an opaque error type, so that the representation is able to evolve + without breaking the crate's public API. + + ```rust + // PublicError is public, but opaque and easy to keep compatible. + #[derive(Error, Debug)] + #[error(transparent)] + pub struct PublicError(#[from] ErrorRepr); + + impl PublicError { + // Accessors for anything we do want to expose publicly. + } + + // Private and free to change across minor version of the crate. + #[derive(Error, Debug)] + enum ErrorRepr { + ... + } + ``` + - See also the [`anyhow`] library for a convenient single error type to use in application code. diff --git a/vendor/thiserror/build.rs b/vendor/thiserror/build.rs new file mode 100644 index 000000000..004dfb015 --- /dev/null +++ b/vendor/thiserror/build.rs @@ -0,0 +1,66 @@ +use std::env; +use std::fs; +use std::path::Path; +use std::process::{Command, ExitStatus, Stdio}; +use std::str; + +// This code exercises the surface area that we expect of the Provider API. If +// the current toolchain is able to compile it, then thiserror is able to use +// providers for backtrace support. +const PROBE: &str = r#" + #![feature(provide_any)] + + use std::any::{Demand, Provider}; + + fn _f<'a, P: Provider>(p: &'a P, demand: &mut Demand<'a>) { + p.provide(demand); + } +"#; + +fn main() { + match compile_probe() { + Some(status) if status.success() => println!("cargo:rustc-cfg=provide_any"), + _ => {} + } +} + +fn compile_probe() -> Option<ExitStatus> { + let rustc = env::var_os("RUSTC")?; + let out_dir = env::var_os("OUT_DIR")?; + let probefile = Path::new(&out_dir).join("probe.rs"); + fs::write(&probefile, PROBE).ok()?; + + // Make sure to pick up Cargo rustc configuration. + let mut cmd = if let Some(wrapper) = env::var_os("RUSTC_WRAPPER") { + let mut cmd = Command::new(wrapper); + // The wrapper's first argument is supposed to be the path to rustc. + cmd.arg(rustc); + cmd + } else { + Command::new(rustc) + }; + + cmd.stderr(Stdio::null()) + .arg("--edition=2018") + .arg("--crate-name=thiserror_build") + .arg("--crate-type=lib") + .arg("--emit=metadata") + .arg("--out-dir") + .arg(out_dir) + .arg(probefile); + + if let Some(target) = env::var_os("TARGET") { + cmd.arg("--target").arg(target); + } + + // If Cargo wants to set RUSTFLAGS, use that. + if let Ok(rustflags) = env::var("CARGO_ENCODED_RUSTFLAGS") { + if !rustflags.is_empty() { + for arg in rustflags.split('\x1f') { + cmd.arg(arg); + } + } + } + + cmd.status().ok() +} diff --git a/vendor/thiserror/src/aserror.rs b/vendor/thiserror/src/aserror.rs index c036b7b09..5fea84ef8 100644 --- a/vendor/thiserror/src/aserror.rs +++ b/vendor/thiserror/src/aserror.rs @@ -1,7 +1,7 @@ use std::error::Error; use std::panic::UnwindSafe; -pub trait AsDynError<'a> { +pub trait AsDynError<'a>: Sealed { fn as_dyn_error(&self) -> &(dyn Error + 'a); } @@ -39,3 +39,10 @@ impl<'a> AsDynError<'a> for dyn Error + Send + Sync + UnwindSafe + 'a { self } } + +pub trait Sealed {} +impl<'a, T: Error + 'a> Sealed for T {} +impl<'a> Sealed for dyn Error + 'a {} +impl<'a> Sealed for dyn Error + Send + 'a {} +impl<'a> Sealed for dyn Error + Send + Sync + 'a {} +impl<'a> Sealed for dyn Error + Send + Sync + UnwindSafe + 'a {} diff --git a/vendor/thiserror/src/lib.rs b/vendor/thiserror/src/lib.rs index 2fae25c54..aae6552d0 100644 --- a/vendor/thiserror/src/lib.rs +++ b/vendor/thiserror/src/lib.rs @@ -2,7 +2,7 @@ //! //! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github //! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust -//! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K +//! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs //! //! <br> //! @@ -146,8 +146,9 @@ //! # } //! ``` //! -//! - The Error trait's `backtrace()` method is implemented to return whichever -//! field has a type named `Backtrace`, if any. +//! - The Error trait's `provide()` method is implemented to provide whichever +//! field has a type named `Backtrace`, if any, as a +//! `std::backtrace::Backtrace`. //! //! ```rust //! # const IGNORE: &str = stringify! { @@ -163,7 +164,8 @@ //! //! - 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. +//! trait's `provide()` method is forwarded to the source's `provide` so that +//! both layers of the error share the same backtrace. //! //! ```rust //! # const IGNORE: &str = stringify! { @@ -196,6 +198,31 @@ //! } //! ``` //! +//! Another use case is hiding implementation details of an error +//! representation behind an opaque error type, so that the representation is +//! able to evolve without breaking the crate's public API. +//! +//! ``` +//! # use thiserror::Error; +//! # +//! // PublicError is public, but opaque and easy to keep compatible. +//! #[derive(Error, Debug)] +//! #[error(transparent)] +//! pub struct PublicError(#[from] ErrorRepr); +//! +//! impl PublicError { +//! // Accessors for anything we do want to expose publicly. +//! } +//! +//! // Private and free to change across minor version of the crate. +//! #[derive(Error, Debug)] +//! enum ErrorRepr { +//! # /* +//! ... +//! # */ +//! } +//! ``` +//! //! - See also the [`anyhow`] library for a convenient single error type to use //! in application code. //! @@ -205,16 +232,23 @@ // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7421 clippy::doc_markdown, clippy::module_name_repetitions, + clippy::return_self_not_must_use, + clippy::wildcard_imports, )] +#![cfg_attr(provide_any, feature(provide_any))] mod aserror; mod display; +#[cfg(provide_any)] +mod provide; pub use thiserror_impl::*; // Not public API. #[doc(hidden)] -pub mod private { +pub mod __private { pub use crate::aserror::AsDynError; pub use crate::display::{DisplayAsDisplay, PathAsDisplay}; + #[cfg(provide_any)] + pub use crate::provide::ThiserrorProvide; } diff --git a/vendor/thiserror/src/provide.rs b/vendor/thiserror/src/provide.rs new file mode 100644 index 000000000..524e7435d --- /dev/null +++ b/vendor/thiserror/src/provide.rs @@ -0,0 +1,15 @@ +use std::any::{Demand, Provider}; + +pub trait ThiserrorProvide: Sealed { + fn thiserror_provide<'a>(&'a self, demand: &mut Demand<'a>); +} + +impl<T: Provider + ?Sized> ThiserrorProvide for T { + #[inline] + fn thiserror_provide<'a>(&'a self, demand: &mut Demand<'a>) { + self.provide(demand); + } +} + +pub trait Sealed {} +impl<T: Provider + ?Sized> Sealed for T {} diff --git a/vendor/thiserror/tests/compiletest.rs b/vendor/thiserror/tests/compiletest.rs index 641d03cbf..7974a6249 100644 --- a/vendor/thiserror/tests/compiletest.rs +++ b/vendor/thiserror/tests/compiletest.rs @@ -1,6 +1,5 @@ -#![deny(clippy::all, clippy::pedantic)] - #[rustversion::attr(not(nightly), ignore)] +#[cfg_attr(miri, ignore)] #[test] fn ui() { let t = trybuild::TestCases::new(); diff --git a/vendor/thiserror/tests/test_backtrace.rs b/vendor/thiserror/tests/test_backtrace.rs index 42e37ca16..43f68b8b7 100644 --- a/vendor/thiserror/tests/test_backtrace.rs +++ b/vendor/thiserror/tests/test_backtrace.rs @@ -1,4 +1,7 @@ -#![cfg_attr(thiserror_nightly_testing, feature(backtrace))] +#![cfg_attr( + thiserror_nightly_testing, + feature(error_generic_member_access, provide_any) +)] use thiserror::Error; @@ -16,6 +19,7 @@ pub struct InnerBacktrace { #[cfg(thiserror_nightly_testing)] pub mod structs { use super::{Inner, InnerBacktrace}; + use std::any; use std::backtrace::Backtrace; use std::error::Error; use std::sync::Arc; @@ -83,49 +87,94 @@ pub mod structs { backtrace: Arc<Backtrace>, } + #[derive(Error, Debug)] + #[error("...")] + pub struct AnyhowBacktrace { + #[backtrace] + source: anyhow::Error, + } + + #[derive(Error, Debug)] + #[error("...")] + pub struct BoxDynErrorBacktrace { + #[backtrace] + source: Box<dyn Error>, + } + #[test] fn test_backtrace() { let error = PlainBacktrace { backtrace: Backtrace::capture(), }; - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = ExplicitBacktrace { backtrace: Backtrace::capture(), }; - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = OptBacktrace { backtrace: Some(Backtrace::capture()), }; - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = ArcBacktrace { backtrace: Arc::new(Backtrace::capture()), }; - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = BacktraceFrom::from(Inner); - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = CombinedBacktraceFrom::from(InnerBacktrace { backtrace: Backtrace::capture(), }); - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = OptBacktraceFrom::from(Inner); - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = ArcBacktraceFrom::from(Inner); - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); + + let error = AnyhowBacktrace { + source: anyhow::Error::msg("..."), + }; + assert!(any::request_ref::<Backtrace>(&error).is_some()); + + let error = BoxDynErrorBacktrace { + source: Box::new(PlainBacktrace { + backtrace: Backtrace::capture(), + }), + }; + assert!(any::request_ref::<Backtrace>(&error).is_some()); + } + + // https://github.com/dtolnay/thiserror/issues/185 -- std::error::Error and + // std::any::Provide both have a method called 'provide', so directly + // calling it from generated code could be ambiguous. + #[test] + fn test_provide_name_collision() { + use std::any::Provider; + + #[derive(Error, Debug)] + #[error("...")] + struct MyError { + #[source] + #[backtrace] + x: std::io::Error, + } + + let _: dyn Error; + let _: dyn Provider; } } #[cfg(thiserror_nightly_testing)] pub mod enums { use super::{Inner, InnerBacktrace}; + use std::any; use std::backtrace::Backtrace; - use std::error::Error; use std::sync::Arc; use thiserror::Error; @@ -210,36 +259,36 @@ pub mod enums { let error = PlainBacktrace::Test { backtrace: Backtrace::capture(), }; - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = ExplicitBacktrace::Test { backtrace: Backtrace::capture(), }; - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = OptBacktrace::Test { backtrace: Some(Backtrace::capture()), }; - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = ArcBacktrace::Test { backtrace: Arc::new(Backtrace::capture()), }; - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = BacktraceFrom::from(Inner); - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = CombinedBacktraceFrom::from(InnerBacktrace { backtrace: Backtrace::capture(), }); - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = OptBacktraceFrom::from(Inner); - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = ArcBacktraceFrom::from(Inner); - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); } } diff --git a/vendor/thiserror/tests/test_deprecated.rs b/vendor/thiserror/tests/test_deprecated.rs new file mode 100644 index 000000000..5524666ab --- /dev/null +++ b/vendor/thiserror/tests/test_deprecated.rs @@ -0,0 +1,10 @@ +#![deny(deprecated, clippy::all, clippy::pedantic)] + +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum Error { + #[deprecated] + #[error("...")] + Deprecated, +} diff --git a/vendor/thiserror/tests/test_display.rs b/vendor/thiserror/tests/test_display.rs index 949d9eda7..8917bb054 100644 --- a/vendor/thiserror/tests/test_display.rs +++ b/vendor/thiserror/tests/test_display.rs @@ -1,5 +1,3 @@ -#![deny(clippy::all, clippy::pedantic)] - use std::fmt::Display; use thiserror::Error; diff --git a/vendor/thiserror/tests/test_error.rs b/vendor/thiserror/tests/test_error.rs index ece7f91a9..fab934d78 100644 --- a/vendor/thiserror/tests/test_error.rs +++ b/vendor/thiserror/tests/test_error.rs @@ -1,4 +1,3 @@ -#![deny(clippy::all, clippy::pedantic)] #![allow(dead_code)] use std::fmt::{self, Display}; diff --git a/vendor/thiserror/tests/test_expr.rs b/vendor/thiserror/tests/test_expr.rs index 87a56cf58..34de56087 100644 --- a/vendor/thiserror/tests/test_expr.rs +++ b/vendor/thiserror/tests/test_expr.rs @@ -1,5 +1,4 @@ -#![deny(clippy::all, clippy::pedantic)] -#![allow(clippy::option_if_let_else)] +#![allow(clippy::iter_cloned_collect, clippy::option_if_let_else)] use std::fmt::Display; use thiserror::Error; diff --git a/vendor/thiserror/tests/test_from.rs b/vendor/thiserror/tests/test_from.rs index a25ce353d..1f387055f 100644 --- a/vendor/thiserror/tests/test_from.rs +++ b/vendor/thiserror/tests/test_from.rs @@ -1,5 +1,3 @@ -#![deny(clippy::all, clippy::pedantic)] - use std::io; use thiserror::Error; diff --git a/vendor/thiserror/tests/test_generics.rs b/vendor/thiserror/tests/test_generics.rs index f5e1de243..4ab9f3778 100644 --- a/vendor/thiserror/tests/test_generics.rs +++ b/vendor/thiserror/tests/test_generics.rs @@ -1,4 +1,4 @@ -#![deny(clippy::all, clippy::pedantic)] +#![allow(clippy::needless_late_init)] use std::fmt::{self, Debug, Display}; use thiserror::Error; diff --git a/vendor/thiserror/tests/test_option.rs b/vendor/thiserror/tests/test_option.rs index ca2171385..ed5287dc9 100644 --- a/vendor/thiserror/tests/test_option.rs +++ b/vendor/thiserror/tests/test_option.rs @@ -1,5 +1,7 @@ -#![cfg_attr(thiserror_nightly_testing, feature(backtrace))] -#![deny(clippy::all, clippy::pedantic)] +#![cfg_attr( + thiserror_nightly_testing, + feature(error_generic_member_access, provide_any) +)] #[cfg(thiserror_nightly_testing)] pub mod structs { diff --git a/vendor/thiserror/tests/test_path.rs b/vendor/thiserror/tests/test_path.rs index a10b1f342..a34a3d74e 100644 --- a/vendor/thiserror/tests/test_path.rs +++ b/vendor/thiserror/tests/test_path.rs @@ -1,5 +1,3 @@ -#![deny(clippy::all, clippy::pedantic)] - use ref_cast::RefCast; use std::fmt::Display; use std::path::{Path, PathBuf}; diff --git a/vendor/thiserror/tests/test_source.rs b/vendor/thiserror/tests/test_source.rs index ab16097b2..637f4ac0a 100644 --- a/vendor/thiserror/tests/test_source.rs +++ b/vendor/thiserror/tests/test_source.rs @@ -1,5 +1,3 @@ -#![deny(clippy::all, clippy::pedantic)] - use std::error::Error as StdError; use std::io; use thiserror::Error; diff --git a/vendor/thiserror/tests/test_transparent.rs b/vendor/thiserror/tests/test_transparent.rs index 84d7c9189..6f3c03ec7 100644 --- a/vendor/thiserror/tests/test_transparent.rs +++ b/vendor/thiserror/tests/test_transparent.rs @@ -1,5 +1,3 @@ -#![deny(clippy::all, clippy::pedantic)] - use anyhow::anyhow; use std::error::Error as _; use std::io; diff --git a/vendor/thiserror/tests/ui/concat-display.stderr b/vendor/thiserror/tests/ui/concat-display.stderr index 6ab40481f..dbecd69f2 100644 --- a/vendor/thiserror/tests/ui/concat-display.stderr +++ b/vendor/thiserror/tests/ui/concat-display.stderr @@ -5,6 +5,6 @@ error: expected string literal | ^^^^^^ ... 13 | error_type!(Error, "foo"); - | -------------------------- in this macro invocation + | ------------------------- in this macro invocation | = note: this error originates in the macro `error_type` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/vendor/thiserror/tests/ui/from-backtrace-backtrace.rs b/vendor/thiserror/tests/ui/from-backtrace-backtrace.rs new file mode 100644 index 000000000..8f411bf5d --- /dev/null +++ b/vendor/thiserror/tests/ui/from-backtrace-backtrace.rs @@ -0,0 +1,10 @@ +// https://github.com/dtolnay/thiserror/issues/163 + +use std::backtrace::Backtrace; +use thiserror::Error; + +#[derive(Error, Debug)] +#[error("...")] +pub struct Error(#[from] #[backtrace] std::io::Error, Backtrace); + +fn main() {} diff --git a/vendor/thiserror/tests/ui/from-backtrace-backtrace.stderr b/vendor/thiserror/tests/ui/from-backtrace-backtrace.stderr new file mode 100644 index 000000000..55d647b42 --- /dev/null +++ b/vendor/thiserror/tests/ui/from-backtrace-backtrace.stderr @@ -0,0 +1,5 @@ +error: deriving From requires no fields other than source and backtrace + --> tests/ui/from-backtrace-backtrace.rs:8:18 + | +8 | pub struct Error(#[from] #[backtrace] std::io::Error, Backtrace); + | ^^^^^^^ diff --git a/vendor/thiserror/tests/ui/no-display.stderr b/vendor/thiserror/tests/ui/no-display.stderr index e6a52f5e7..82c3eea1c 100644 --- a/vendor/thiserror/tests/ui/no-display.stderr +++ b/vendor/thiserror/tests/ui/no-display.stderr @@ -2,7 +2,7 @@ error[E0599]: the method `as_display` exists for reference `&NoDisplay`, but its --> tests/ui/no-display.rs:7:9 | 4 | struct NoDisplay; - | ----------------- doesn't satisfy `NoDisplay: std::fmt::Display` + | ---------------- doesn't satisfy `NoDisplay: std::fmt::Display` ... 7 | #[error("thread: {thread}")] | ^^^^^^^^^^^^^^^^^^ method cannot be called on `&NoDisplay` due to unsatisfied trait bounds @@ -13,11 +13,5 @@ error[E0599]: the method `as_display` exists for reference `&NoDisplay`, but its 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; - | | } - | |_^ + | pub trait Display { + | ^^^^^^^^^^^^^^^^^ diff --git a/vendor/thiserror/tests/ui/source-enum-not-error.stderr b/vendor/thiserror/tests/ui/source-enum-not-error.stderr index d01cba5b0..29ee54600 100644 --- a/vendor/thiserror/tests/ui/source-enum-not-error.stderr +++ b/vendor/thiserror/tests/ui/source-enum-not-error.stderr @@ -1,28 +1,22 @@ error[E0599]: the method `as_dyn_error` exists for reference `&NotError`, but its trait bounds were not satisfied - --> 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` + --> 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 -... | - | | } - | | } - | |_^ + --> $RUST/core/src/error.rs + | + | pub trait Error: Debug + Display { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/vendor/thiserror/tests/ui/source-struct-not-error.stderr b/vendor/thiserror/tests/ui/source-struct-not-error.stderr index be1331a50..efa40281d 100644 --- a/vendor/thiserror/tests/ui/source-struct-not-error.stderr +++ b/vendor/thiserror/tests/ui/source-struct-not-error.stderr @@ -1,27 +1,21 @@ error[E0599]: the method `as_dyn_error` exists for struct `NotError`, but its trait bounds were not satisfied - --> 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` + --> tests/ui/source-struct-not-error.rs:9:5 + | +4 | struct NotError; + | --------------- + | | + | method `as_dyn_error` not found for this struct + | 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 -... | - | | } - | | } - | |_^ + --> $RUST/core/src/error.rs + | + | pub trait Error: Debug + Display { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |