This repository was archived by the owner on Aug 16, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ fn main() {
1010 println ! ( "cargo:rustc-cfg=has_error_source" ) ;
1111 }
1212
13+ if is_min_version ( "1.42" ) . unwrap_or ( false ) {
14+ println ! ( "cargo:rustc-cfg=has_error_description_deprecated" ) ;
15+ }
16+
1317 // So we can get the build profile for has_backtrace_depending_on_env test
1418 if let Ok ( profile) = env:: var ( "PROFILE" ) {
1519 println ! ( "cargo:rustc-cfg=build={:?}" , profile) ;
Original file line number Diff line number Diff line change @@ -68,6 +68,21 @@ macro_rules! impl_error_chain_cause_or_source {
6868 } ;
6969}
7070
71+ /// Conditional usage of deprecated Error::description
72+ #[ doc( hidden) ]
73+ #[ cfg( has_error_description_deprecated) ]
74+ #[ macro_export( local_inner_macros) ]
75+ macro_rules! call_to_deprecated_description {
76+ ( $e: ident) => { "" } ;
77+ }
78+
79+ #[ doc( hidden) ]
80+ #[ cfg( not( has_error_description_deprecated) ) ]
81+ #[ macro_export( local_inner_macros) ]
82+ macro_rules! call_to_deprecated_description {
83+ ( $e: ident) => { :: std:: error:: Error :: description( $e) } ;
84+ }
85+
7186/// Prefer to use `error_chain` instead of this macro.
7287#[ doc( hidden) ]
7388#[ macro_export( local_inner_macros) ]
@@ -301,6 +316,7 @@ macro_rules! impl_error_chain_processed {
301316 }
302317
303318 impl :: std:: error:: Error for $error_name {
319+ #[ cfg( not( has_error_description_deprecated) ) ]
304320 fn description( & self ) -> & str {
305321 self . description( )
306322 }
@@ -369,7 +385,7 @@ macro_rules! impl_error_chain_processed {
369385 $(
370386 $( #[ $meta_foreign_links] ) *
371387 $foreign_link_variant( err: $foreign_link_error_path) {
372- description( :: std :: error :: Error :: description ( err) )
388+ description( call_to_deprecated_description! ( err) )
373389 display( "{}" , err)
374390 }
375391 ) *
You can’t perform that action at this time.
0 commit comments