Skip to content

Commit

Permalink
Access Backtrace exclusively through ::thiserror
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Nov 6, 2024
1 parent d14adfb commit bd660ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 10 additions & 10 deletions impl/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ fn impl_struct(input: Struct) -> TokenStream {
} else if type_is_option(backtrace_field.ty) {
Some(quote! {
if let ::core::option::Option::Some(backtrace) = &self.#backtrace {
#request.provide_ref::<::std::backtrace::Backtrace>(backtrace);
#request.provide_ref::<::thiserror::__private::Backtrace>(backtrace);
}
})
} else {
Some(quote! {
#request.provide_ref::<::std::backtrace::Backtrace>(&self.#backtrace);
#request.provide_ref::<::thiserror::__private::Backtrace>(&self.#backtrace);
})
};
quote! {
Expand All @@ -134,12 +134,12 @@ fn impl_struct(input: Struct) -> TokenStream {
} else if type_is_option(backtrace_field.ty) {
quote! {
if let ::core::option::Option::Some(backtrace) = &self.#backtrace {
#request.provide_ref::<::std::backtrace::Backtrace>(backtrace);
#request.provide_ref::<::thiserror::__private::Backtrace>(backtrace);
}
}
} else {
quote! {
#request.provide_ref::<::std::backtrace::Backtrace>(&self.#backtrace);
#request.provide_ref::<::thiserror::__private::Backtrace>(&self.#backtrace);
}
};
quote! {
Expand Down Expand Up @@ -309,12 +309,12 @@ fn impl_enum(input: Enum) -> TokenStream {
let self_provide = if type_is_option(backtrace_field.ty) {
quote! {
if let ::core::option::Option::Some(backtrace) = backtrace {
#request.provide_ref::<::std::backtrace::Backtrace>(backtrace);
#request.provide_ref::<::thiserror::__private::Backtrace>(backtrace);
}
}
} else {
quote! {
#request.provide_ref::<::std::backtrace::Backtrace>(backtrace);
#request.provide_ref::<::thiserror::__private::Backtrace>(backtrace);
}
};
quote! {
Expand Down Expand Up @@ -357,12 +357,12 @@ fn impl_enum(input: Enum) -> TokenStream {
let body = if type_is_option(backtrace_field.ty) {
quote! {
if let ::core::option::Option::Some(backtrace) = backtrace {
#request.provide_ref::<::std::backtrace::Backtrace>(backtrace);
#request.provide_ref::<::thiserror::__private::Backtrace>(backtrace);
}
}
} else {
quote! {
#request.provide_ref::<::std::backtrace::Backtrace>(backtrace);
#request.provide_ref::<::thiserror::__private::Backtrace>(backtrace);
}
};
quote! {
Expand Down Expand Up @@ -532,11 +532,11 @@ fn from_initializer(
let backtrace_member = &backtrace_field.member;
if type_is_option(backtrace_field.ty) {
quote! {
#backtrace_member: ::core::option::Option::Some(::std::backtrace::Backtrace::capture()),
#backtrace_member: ::core::option::Option::Some(::thiserror::__private::Backtrace::capture()),
}
} else {
quote! {
#backtrace_member: ::core::convert::From::from(::std::backtrace::Backtrace::capture()),
#backtrace_member: ::core::convert::From::from(::thiserror::__private::Backtrace::capture()),
}
}
});
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,5 +288,7 @@ pub mod __private {
#[doc(hidden)]
pub use crate::provide::ThiserrorProvide;
#[doc(hidden)]
pub use std::backtrace::Backtrace;
#[doc(hidden)]
pub use std::error::Error;
}

0 comments on commit bd660ef

Please sign in to comment.