1 #![forbid(unsafe_code)] 2 #![deny( 3 anonymous_parameters, 4 rust_2018_idioms, 5 trivial_casts, 6 trivial_numeric_casts, 7 unreachable_pub, 8 const_err, 9 illegal_floating_point_literal_pattern, 10 late_bound_lifetime_arguments, 11 path_statements, 12 patterns_in_fns_without_body, 13 clippy::all 14 )] 15 #![warn( 16 unused_extern_crates, 17 missing_copy_implementations, 18 missing_debug_implementations, 19 single_use_lifetimes, 20 unused_qualifications, 21 variant_size_differences, 22 clippy::pedantic, 23 clippy::nursery, 24 clippy::decimal_literal_representation, 25 clippy::get_unwrap, 26 clippy::option_unwrap_used, 27 clippy::print_stdout, 28 clippy::result_unwrap_used 29 )] 30 #![allow( 31 clippy::inline_always, 32 clippy::cast_possible_wrap, 33 clippy::cast_lossless, 34 clippy::module_name_repetitions, 35 clippy::must_use_candidate, 36 clippy::use_self, // Not supported in some situations in older compilers. 37 )] 38 39 // This is required on rustc < 1.42.0. 40 #[allow(unused_extern_crates)] 41 extern crate proc_macro; 42 43 macro_rules! error { 44 ($message:literal) => { 45 error!(::proc_macro2::Span::call_site(), $message) 46 }; 47 48 ($span:expr, $message:literal) => { 49 Err(::syn::Error::new($span, $message)) 50 }; 51 52 ($span:expr, $($args:expr),+) => { 53 Err(::syn::Error::new($span, format!($($args),+))) 54 }; 55 } 56 57 mod kw { 58 use syn::custom_keyword; 59 custom_keyword!(am); 60 custom_keyword!(pm); 61 custom_keyword!(AM); 62 custom_keyword!(PM); 63 custom_keyword!(utc); 64 custom_keyword!(UTC); 65 } 66 67 mod date; 68 mod ext; 69 mod offset; 70 mod time; 71 mod time_crate; 72 73 use date::Date; 74 use offset::Offset; 75 use proc_macro_hack::proc_macro_hack; 76 use quote::ToTokens; 77 use syn::parse_macro_input; 78 use time::Time; 79 80 macro_rules! impl_macros { 81 ($($name:ident : $type:ty),* $(,)?) => { 82 $( 83 #[proc_macro_hack] 84 pub fn $name(input: proc_macro::TokenStream) -> proc_macro::TokenStream { 85 parse_macro_input!(input as $type).to_token_stream().into() 86 } 87 )* 88 }; 89 } 90 91 impl_macros! { 92 time: Time, 93 offset: Offset, 94 date: Date, 95 } 96