thiserror_impl/
fallback.rs1use crate::expand::call_site_ident;
2use proc_macro2::TokenStream;
3use quote::quote;
4use syn::DeriveInput;
5
6pub(crate) fn expand(input: &DeriveInput, error: syn::Error) -> TokenStream {
7 let ty = call_site_ident(&input.ident);
8 let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();
9
10 let error = error.to_compile_error();
11
12 quote! {
13 #error
14
15 #[allow(unused_qualifications)]
16 #[automatically_derived]
17 impl #impl_generics ::thiserror::__private::Error for #ty #ty_generics #where_clause
18 where
19 for<'workaround> #ty #ty_generics: ::core::fmt::Debug,
22 {}
23
24 #[allow(unused_qualifications)]
25 #[automatically_derived]
26 impl #impl_generics ::core::fmt::Display for #ty #ty_generics #where_clause {
27 fn fmt(&self, __formatter: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
28 ::core::unreachable!()
29 }
30 }
31 }
32}