This repository was archived by the owner on Aug 16, 2021. It is now read-only.
File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ fn main() {
10
10
println ! ( "cargo:rustc-cfg=has_error_source" ) ;
11
11
}
12
12
13
+ if is_min_version ( "1.42" ) . unwrap_or ( false ) {
14
+ println ! ( "cargo:rustc-cfg=has_error_description_deprecated" ) ;
15
+ }
16
+
13
17
// So we can get the build profile for has_backtrace_depending_on_env test
14
18
if let Ok ( profile) = env:: var ( "PROFILE" ) {
15
19
println ! ( "cargo:rustc-cfg=build={:?}" , profile) ;
Original file line number Diff line number Diff line change @@ -68,6 +68,20 @@ macro_rules! impl_error_chain_cause_or_source {
68
68
} ;
69
69
}
70
70
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
+ #[ cfg( not( has_error_description_deprecated) ) ]
80
+ #[ macro_export( local_inner_macros) ]
81
+ macro_rules! call_to_deprecated_description {
82
+ ( $e: ident) => { :: std:: error:: Error :: description( $e) } ;
83
+ }
84
+
71
85
/// Prefer to use `error_chain` instead of this macro.
72
86
#[ doc( hidden) ]
73
87
#[ macro_export( local_inner_macros) ]
@@ -301,6 +315,7 @@ macro_rules! impl_error_chain_processed {
301
315
}
302
316
303
317
impl :: std:: error:: Error for $error_name {
318
+ #[ cfg( not( has_error_description_deprecated) ) ]
304
319
fn description( & self ) -> & str {
305
320
self . description( )
306
321
}
@@ -369,7 +384,7 @@ macro_rules! impl_error_chain_processed {
369
384
$(
370
385
$( #[ $meta_foreign_links] ) *
371
386
$foreign_link_variant( err: $foreign_link_error_path) {
372
- description( :: std :: error :: Error :: description ( err) )
387
+ description( call_to_deprecated_description! ( err) )
373
388
display( "{}" , err)
374
389
}
375
390
) *
You can’t perform that action at this time.
0 commit comments