serde_derive/
dummy.rs
1use proc_macro2::TokenStream;
2use quote::quote;
3
4pub fn wrap_in_const(serde_path: Option<&syn::Path>, code: TokenStream) -> TokenStream {
5 let use_serde = match serde_path {
6 Some(path) => quote! {
7 use #path as _serde;
8 },
9 None => quote! {
10 #[allow(unused_extern_crates, clippy::useless_attribute)]
11 extern crate serde as _serde;
12 },
13 };
14
15 quote! {
16 #[doc(hidden)]
17 #[allow(
18 non_upper_case_globals,
19 unused_attributes,
20 unused_qualifications,
21 clippy::absolute_paths,
22 )]
23 const _: () = {
24 #use_serde
25 #code
26 };
27 }
28}