changeset 99:0444f8e3099d

Merge pull request #25 from blyxyas/master Add `compile_error`
author Lewin Bormann <lbo@spheniscida.de>
date Wed, 18 Jan 2023 22:19:05 +0100
parents 525fcf2058ae (current diff) e3495f149cdd (diff)
children f0d6ef116542
files
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/inner/src/lib.rs	Sun Jan 15 18:41:31 2023 +0100
+++ b/inner/src/lib.rs	Wed Jan 18 22:19:05 2023 +0100
@@ -1,6 +1,5 @@
 #![crate_type = "proc-macro"]
 #![allow(unused_imports)] // Spurious complaints about a required trait import.
-
 use syn::{self, parse, parse_macro_input, spanned::Spanned, Expr, ExprCall, ItemFn, Path};
 
 use proc_macro::TokenStream;
@@ -179,7 +178,10 @@
             }
             Some(cap) => {
                 if let Some(_) = &options.custom_hasher {
-                    panic!("You can't use LRUMaxEntries and a Custom Hasher. Remove `LRUMaxEntries` from the attribute");
+                    (
+                        quote::quote! { compile_error!("Cannot use LRU cache and a custom hasher at the same time") },
+                        quote::quote! { std::collections::HashMap::new() },
+                    )
                 } else {
                     (
                         quote::quote! { ::memoize::lru::LruCache<#key_type, #value_type> },