@@ -2,6 +2,7 @@ use crate::ast::{Enum, Field, Input, Struct};
22use crate :: attr:: Trait ;
33use crate :: fallback;
44use crate :: generics:: InferredBounds ;
5+ use crate :: private;
56use crate :: unraw:: MemberUnraw ;
67use proc_macro2:: { Ident , Span , TokenStream } ;
78use quote:: { format_ident, quote, quote_spanned, ToTokens } ;
@@ -35,17 +36,17 @@ fn impl_struct(input: Struct) -> TokenStream {
3536 let source_body = if let Some ( transparent_attr) = & input. attrs . transparent {
3637 let only_field = & input. fields [ 0 ] ;
3738 if only_field. contains_generic {
38- error_inferred_bounds. insert ( only_field. ty , quote ! ( :: thiserror:: __private :: Error ) ) ;
39+ error_inferred_bounds. insert ( only_field. ty , quote ! ( :: thiserror:: #private :: Error ) ) ;
3940 }
4041 let member = & only_field. member ;
4142 Some ( quote_spanned ! { transparent_attr. span=>
42- :: thiserror:: __private :: Error :: source( self . #member. as_dyn_error( ) )
43+ :: thiserror:: #private :: Error :: source( self . #member. as_dyn_error( ) )
4344 } )
4445 } else if let Some ( source_field) = input. source_field ( ) {
4546 let source = & source_field. member ;
4647 if source_field. contains_generic {
4748 let ty = unoptional_type ( source_field. ty ) ;
48- error_inferred_bounds. insert ( ty, quote ! ( :: thiserror:: __private :: Error + ' static ) ) ;
49+ error_inferred_bounds. insert ( ty, quote ! ( :: thiserror:: #private :: Error + ' static ) ) ;
4950 }
5051 let asref = if type_is_option ( source_field. ty ) {
5152 Some ( quote_spanned ! ( source. span( ) => . as_ref( ) ?) )
@@ -63,8 +64,8 @@ fn impl_struct(input: Struct) -> TokenStream {
6364 } ;
6465 let source_method = source_body. map ( |body| {
6566 quote ! {
66- fn source( & self ) -> :: core:: option:: Option <& ( dyn :: thiserror:: __private :: Error + ' static ) > {
67- use :: thiserror:: __private :: AsDynError as _;
67+ fn source( & self ) -> :: core:: option:: Option <& ( dyn :: thiserror:: #private :: Error + ' static ) > {
68+ use :: thiserror:: #private :: AsDynError as _;
6869 #body
6970 }
7071 }
@@ -91,28 +92,28 @@ fn impl_struct(input: Struct) -> TokenStream {
9192 } else if type_is_option ( backtrace_field. ty ) {
9293 Some ( quote ! {
9394 if let :: core:: option:: Option :: Some ( backtrace) = & self . #backtrace {
94- #request. provide_ref:: <:: thiserror:: __private :: Backtrace >( backtrace) ;
95+ #request. provide_ref:: <:: thiserror:: #private :: Backtrace >( backtrace) ;
9596 }
9697 } )
9798 } else {
9899 Some ( quote ! {
99- #request. provide_ref:: <:: thiserror:: __private :: Backtrace >( & self . #backtrace) ;
100+ #request. provide_ref:: <:: thiserror:: #private :: Backtrace >( & self . #backtrace) ;
100101 } )
101102 } ;
102103 quote ! {
103- use :: thiserror:: __private :: ThiserrorProvide as _;
104+ use :: thiserror:: #private :: ThiserrorProvide as _;
104105 #source_provide
105106 #self_provide
106107 }
107108 } else if type_is_option ( backtrace_field. ty ) {
108109 quote ! {
109110 if let :: core:: option:: Option :: Some ( backtrace) = & self . #backtrace {
110- #request. provide_ref:: <:: thiserror:: __private :: Backtrace >( backtrace) ;
111+ #request. provide_ref:: <:: thiserror:: #private :: Backtrace >( backtrace) ;
111112 }
112113 }
113114 } else {
114115 quote ! {
115- #request. provide_ref:: <:: thiserror:: __private :: Backtrace >( & self . #backtrace) ;
116+ #request. provide_ref:: <:: thiserror:: #private :: Backtrace >( & self . #backtrace) ;
116117 }
117118 } ;
118119 quote ! {
@@ -201,7 +202,7 @@ fn impl_struct(input: Struct) -> TokenStream {
201202 quote ! {
202203 #[ allow( unused_qualifications) ]
203204 #[ automatically_derived]
204- impl #impl_generics :: thiserror:: __private :: Error for #ty #ty_generics #error_where_clause {
205+ impl #impl_generics :: thiserror:: #private :: Error for #ty #ty_generics #error_where_clause {
205206 #source_method
206207 #provide_method
207208 }
@@ -221,11 +222,11 @@ fn impl_enum(input: Enum) -> TokenStream {
221222 if let Some ( transparent_attr) = & variant. attrs . transparent {
222223 let only_field = & variant. fields [ 0 ] ;
223224 if only_field. contains_generic {
224- error_inferred_bounds. insert ( only_field. ty , quote ! ( :: thiserror:: __private :: Error ) ) ;
225+ error_inferred_bounds. insert ( only_field. ty , quote ! ( :: thiserror:: #private :: Error ) ) ;
225226 }
226227 let member = & only_field. member ;
227228 let source = quote_spanned ! { transparent_attr. span=>
228- :: thiserror:: __private :: Error :: source( transparent. as_dyn_error( ) )
229+ :: thiserror:: #private :: Error :: source( transparent. as_dyn_error( ) )
229230 } ;
230231 quote ! {
231232 #ty:: #ident { #member: transparent} => #source,
@@ -234,7 +235,7 @@ fn impl_enum(input: Enum) -> TokenStream {
234235 let source = & source_field. member ;
235236 if source_field. contains_generic {
236237 let ty = unoptional_type ( source_field. ty ) ;
237- error_inferred_bounds. insert ( ty, quote ! ( :: thiserror:: __private :: Error + ' static ) ) ;
238+ error_inferred_bounds. insert ( ty, quote ! ( :: thiserror:: #private :: Error + ' static ) ) ;
238239 }
239240 let asref = if type_is_option ( source_field. ty ) {
240241 Some ( quote_spanned ! ( source. span( ) => . as_ref( ) ?) )
@@ -255,8 +256,8 @@ fn impl_enum(input: Enum) -> TokenStream {
255256 }
256257 } ) ;
257258 Some ( quote ! {
258- fn source( & self ) -> :: core:: option:: Option <& ( dyn :: thiserror:: __private :: Error + ' static ) > {
259- use :: thiserror:: __private :: AsDynError as _;
259+ fn source( & self ) -> :: core:: option:: Option <& ( dyn :: thiserror:: #private :: Error + ' static ) > {
260+ use :: thiserror:: #private :: AsDynError as _;
260261 #[ allow( deprecated) ]
261262 match self {
262263 #( #arms) *
@@ -292,12 +293,12 @@ fn impl_enum(input: Enum) -> TokenStream {
292293 let self_provide = if type_is_option ( backtrace_field. ty ) {
293294 quote ! {
294295 if let :: core:: option:: Option :: Some ( backtrace) = backtrace {
295- #request. provide_ref:: <:: thiserror:: __private :: Backtrace >( backtrace) ;
296+ #request. provide_ref:: <:: thiserror:: #private :: Backtrace >( backtrace) ;
296297 }
297298 }
298299 } else {
299300 quote ! {
300- #request. provide_ref:: <:: thiserror:: __private :: Backtrace >( backtrace) ;
301+ #request. provide_ref:: <:: thiserror:: #private :: Backtrace >( backtrace) ;
301302 }
302303 } ;
303304 quote ! {
@@ -306,7 +307,7 @@ fn impl_enum(input: Enum) -> TokenStream {
306307 #source: #varsource,
307308 ..
308309 } => {
309- use :: thiserror:: __private :: ThiserrorProvide as _;
310+ use :: thiserror:: #private :: ThiserrorProvide as _;
310311 #source_provide
311312 #self_provide
312313 }
@@ -330,7 +331,7 @@ fn impl_enum(input: Enum) -> TokenStream {
330331 } ;
331332 quote ! {
332333 #ty:: #ident { #backtrace: #varsource, ..} => {
333- use :: thiserror:: __private :: ThiserrorProvide as _;
334+ use :: thiserror:: #private :: ThiserrorProvide as _;
334335 #source_provide
335336 }
336337 }
@@ -340,12 +341,12 @@ fn impl_enum(input: Enum) -> TokenStream {
340341 let body = if type_is_option ( backtrace_field. ty ) {
341342 quote ! {
342343 if let :: core:: option:: Option :: Some ( backtrace) = backtrace {
343- #request. provide_ref:: <:: thiserror:: __private :: Backtrace >( backtrace) ;
344+ #request. provide_ref:: <:: thiserror:: #private :: Backtrace >( backtrace) ;
344345 }
345346 }
346347 } else {
347348 quote ! {
348- #request. provide_ref:: <:: thiserror:: __private :: Backtrace >( backtrace) ;
349+ #request. provide_ref:: <:: thiserror:: #private :: Backtrace >( backtrace) ;
349350 }
350351 } ;
351352 quote ! {
@@ -476,7 +477,7 @@ fn impl_enum(input: Enum) -> TokenStream {
476477 quote ! {
477478 #[ allow( unused_qualifications) ]
478479 #[ automatically_derived]
479- impl #impl_generics :: thiserror:: __private :: Error for #ty #ty_generics #error_where_clause {
480+ impl #impl_generics :: thiserror:: #private :: Error for #ty #ty_generics #error_where_clause {
480481 #source_method
481482 #provide_method
482483 }
@@ -511,7 +512,7 @@ fn fields_pat(fields: &[Field]) -> TokenStream {
511512fn use_as_display ( needs_as_display : bool ) -> Option < TokenStream > {
512513 if needs_as_display {
513514 Some ( quote ! {
514- use :: thiserror:: __private :: AsDisplay as _;
515+ use :: thiserror:: #private :: AsDisplay as _;
515516 } )
516517 } else {
517518 None
@@ -533,11 +534,11 @@ fn from_initializer(
533534 let backtrace_member = & backtrace_field. member ;
534535 if type_is_option ( backtrace_field. ty ) {
535536 quote ! {
536- #backtrace_member: :: core:: option:: Option :: Some ( :: thiserror:: __private :: Backtrace :: capture( ) ) ,
537+ #backtrace_member: :: core:: option:: Option :: Some ( :: thiserror:: #private :: Backtrace :: capture( ) ) ,
537538 }
538539 } else {
539540 quote ! {
540- #backtrace_member: :: core:: convert:: From :: from( :: thiserror:: __private :: Backtrace :: capture( ) ) ,
541+ #backtrace_member: :: core:: convert:: From :: from( :: thiserror:: #private :: Backtrace :: capture( ) ) ,
541542 }
542543 }
543544 } ) ;
0 commit comments