| 1 |
use crate::expand::call_site_ident; |
| 2 |
use crate::private; |
| 3 |
use proc_macro2::TokenStream; |
| 4 |
use quote::quote; |
| 5 |
use syn::DeriveInput; |
| 6 |
|
| 7 |
pub(crate) fn expand(input: &DeriveInput, error: syn::Error) -> TokenStream { |
| 8 |
let ty = call_site_ident(&input.ident); |
| 9 |
let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); |
| 10 |
|
| 11 |
let error = error.to_compile_error(); |
| 12 |
|
| 13 |
quote! { |
| 14 |
#error |
| 15 |
|
| 16 |
#[allow(unused_qualifications)] |
| 17 |
#[automatically_derived] |
| 18 |
impl #impl_generics ::thiserror::#private::Error for #ty #ty_generics #where_clause |
| 19 |
where |
| 20 |
// Work around trivial bounds being unstable. |
| 21 |
// https://github.com/rust-lang/rust/issues/48214 |
| 22 |
for<'workaround> #ty #ty_generics: ::core::fmt::Debug, |
| 23 |
{} |
| 24 |
|
| 25 |
#[allow(unused_qualifications)] |
| 26 |
#[automatically_derived] |
| 27 |
impl #impl_generics ::core::fmt::Display for #ty #ty_generics #where_clause { |
| 28 |
fn fmt(&self, __formatter: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { |
| 29 |
::core::unreachable!() |
| 30 |
} |
| 31 |
} |
| 32 |
} |
| 33 |
} |