Skip to content

Codegen bug: broken macro #311

Closed

Description

@boozook

crate: string_cache_codegen v0.11

build.rs:

let mut cache = string_cache_codegen::AtomType::new("my:BundledApiAtom", "my_atom!");
cache.atom("unsafe extern \"C\" fn (sprite : * mut Sprite , pattern : * mut [u8 ; 8usize])");

lib.rs:

my_atom!("unsafe extern \"C\" fn (sprite : * mut Sprite , pattern : * mut [u8 ; 8usize])")

This is error because codegen produced macro like this:

// ...
("unsafe extern \"C\" fn (sprite : * mut Sprite , pattern : * mut [u8 ;
8usize])") => { $ crate :: my :: ATOM_BUNDLEDAPIATOM__75_6E_73_61_66_65_20_65_78_74_65_72_6E_20_22_43_22_20_66_6E_20_28_73_70_72_69_74_65_20_3A_20_2A_20_6D_75_74_20_53_70_72_69_74_65_20_2C_20_70_61_74_74_65_72_6E_20_3A_20_2A_20_6D_75_74_20_5B_75_38_20_3B_20_38_75_73_69_7A_65_5D_29 } ;
// ...

This is heppening because of this:

// Insert some newlines to make the generated code slightly easier to read.
.replace(" [ \"", "[\n\"")
.replace("\" , ", "\",\n")
.replace(" ( \"", "\n( \"")
.replace("; ", ";\n")

Activity

  1. added a commit that references this issue on Sep 11, 2026
    94101c4
  2. SimonSapin commented on Sep 14, 2026

    @SimonSapin
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions