Skip to content

Commit 3bcad59

Browse files
committed
Revert "Directly call source.provide instead of going through dyn error"
This reverts commit f924c25.
1 parent 21198c9 commit 3bcad59

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

Diff for: impl/src/expand.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ fn impl_struct(input: Struct) -> TokenStream {
6767
let source_provide = if type_is_option(source_field.ty) {
6868
quote_spanned! {source.span()=>
6969
if let std::option::Option::Some(source) = &self.#source {
70-
source.provide(#demand);
70+
source.as_dyn_error().provide(#demand);
7171
}
7272
}
7373
} else {
7474
quote_spanned! {source.span()=>
75-
self.#source.provide(#demand);
75+
self.#source.as_dyn_error().provide(#demand);
7676
}
7777
};
7878
let self_provide = if source == backtrace {
@@ -89,8 +89,7 @@ fn impl_struct(input: Struct) -> TokenStream {
8989
})
9090
};
9191
quote! {
92-
#[allow(unused_imports)]
93-
use std::error::Error as _;
92+
use thiserror::__private::AsDynError;
9493
#source_provide
9594
#self_provide
9695
}
@@ -260,12 +259,12 @@ fn impl_enum(input: Enum) -> TokenStream {
260259
let source_provide = if type_is_option(source_field.ty) {
261260
quote_spanned! {source.span()=>
262261
if let std::option::Option::Some(source) = #varsource {
263-
source.provide(#demand);
262+
source.as_dyn_error().provide(#demand);
264263
}
265264
}
266265
} else {
267266
quote_spanned! {source.span()=>
268-
#varsource.provide(#demand);
267+
#varsource.as_dyn_error().provide(#demand);
269268
}
270269
};
271270
let self_provide = if type_is_option(backtrace_field.ty) {
@@ -285,8 +284,7 @@ fn impl_enum(input: Enum) -> TokenStream {
285284
#source: #varsource,
286285
..
287286
} => {
288-
#[allow(unused_imports)]
289-
use std::error::Error as _;
287+
use thiserror::__private::AsDynError;
290288
#source_provide
291289
#self_provide
292290
}
@@ -300,18 +298,17 @@ fn impl_enum(input: Enum) -> TokenStream {
300298
let source_provide = if type_is_option(source_field.ty) {
301299
quote_spanned! {backtrace.span()=>
302300
if let std::option::Option::Some(source) = #varsource {
303-
source.provide(#demand);
301+
source.as_dyn_error().provide(#demand);
304302
}
305303
}
306304
} else {
307305
quote_spanned! {backtrace.span()=>
308-
#varsource.provide(#demand);
306+
#varsource.as_dyn_error().provide(#demand);
309307
}
310308
};
311309
quote! {
312310
#ty::#ident {#backtrace: #varsource, ..} => {
313-
#[allow(unused_imports)]
314-
use std::error::Error as _;
311+
use thiserror::__private::AsDynError;
315312
#source_provide
316313
}
317314
}

0 commit comments

Comments
 (0)