MCPcopy Create free account
hub / github.com/dtolnay/thiserror / expand

Function expand

impl/src/fallback.rs:7–33  ·  view source on GitHub ↗
(input: &DeriveInput, error: syn::Error)

Source from the content-addressed store, hash-verified

5use syn::DeriveInput;
6
7pub(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}

Callers 1

deriveFunction · 0.85

Calls 1

call_site_identFunction · 0.85

Tested by

no test coverage detected