feat: rustc and clippy linting
This commit is contained in:
@@ -20,7 +20,7 @@ pub(crate) fn derive(input: &DeriveInput) -> TokenStream {
|
||||
}
|
||||
}
|
||||
|
||||
fn hashable_struct(input: &DeriveInput, struct_data: &syn::DataStruct) -> TokenStream {
|
||||
fn hashable_struct(input: &DeriveInput, struct_data: &DataStruct) -> TokenStream {
|
||||
let ident = &input.ident;
|
||||
let hashable_trait = HASHABLE_TRAIT_PATH.to_path();
|
||||
let hmac_digest = HMAC_DIGEST_PATH.to_path();
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
pub struct ToPath(pub &'static str);
|
||||
pub(crate) struct ToPath(pub &'static str);
|
||||
|
||||
impl ToPath {
|
||||
pub fn to_path(&self) -> syn::Path {
|
||||
pub(crate) fn to_path(&self) -> syn::Path {
|
||||
syn::parse_str(self.0).expect("Invalid path")
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! ensure_path {
|
||||
($path:path) => {{
|
||||
#[cfg(test)]
|
||||
#[expect(unused_imports)]
|
||||
use $path as _;
|
||||
ToPath(stringify!($path))
|
||||
}};
|
||||
($path:path as $name:ident) => {
|
||||
const _: () = {
|
||||
#[cfg(test)]
|
||||
#[expect(
|
||||
unused_imports,
|
||||
reason = "Ensures the path is valid and will cause a compile error if not"
|
||||
)]
|
||||
use $path as _;
|
||||
};
|
||||
pub(crate) const $name: ToPath = ToPath(stringify!($path));
|
||||
};
|
||||
}
|
||||
|
||||
pub const HASHABLE_TRAIT_PATH: ToPath = ensure_path!(::arbiter_crypto::hashing::Hashable);
|
||||
pub const HMAC_DIGEST_PATH: ToPath = ensure_path!(::arbiter_crypto::hashing::Digest);
|
||||
ensure_path!(::arbiter_crypto::hashing::Hashable as HASHABLE_TRAIT_PATH);
|
||||
ensure_path!(::arbiter_crypto::hashing::Digest as HMAC_DIGEST_PATH);
|
||||
|
||||
Reference in New Issue
Block a user