From 66be05d2710f0f48410ca407ec3865e43686e75d Mon Sep 17 00:00:00 2001 From: Philip Sampaio Date: Fri, 5 Jan 2024 19:07:21 -0300 Subject: [PATCH] Fix atoms module name generated by the `NifStruct` derive macro This is related to https://github.com/rusterlium/rustler/pull/573, but now the macro is given a warning even with the annotation to ignore. So this is a fix that turns the atoms module name generated by the macro in a snake case name. --- rustler_codegen/src/context.rs | 5 ++++- rustler_codegen/src/ex_struct.rs | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/rustler_codegen/src/context.rs b/rustler_codegen/src/context.rs index 6988734c..077da964 100644 --- a/rustler_codegen/src/context.rs +++ b/rustler_codegen/src/context.rs @@ -86,7 +86,10 @@ impl<'a> Context<'a> { } pub fn atoms_module_name(&self, span: Span) -> Ident { - Ident::new(&format!("RUSTLER_ATOMS_{}", self.ident), span) + Ident::new( + &format!("rustler_atoms_{}", self.ident).to_snake_case(), + span, + ) } pub fn encode(&self) -> bool { diff --git a/rustler_codegen/src/ex_struct.rs b/rustler_codegen/src/ex_struct.rs index 4d720606..e051c494 100644 --- a/rustler_codegen/src/ex_struct.rs +++ b/rustler_codegen/src/ex_struct.rs @@ -53,7 +53,6 @@ pub fn transcoder_decorator(ast: &syn::DeriveInput, add_exception: bool) -> Toke }; let gen = quote! { - #[allow(non_snake_case)] mod #atoms_module_name { #atom_defs }