How to use two packages with the same name in one workspace?

Hi there, I am searching for a reasonable solution to the following cargo error:

two packages named `macros` in this workspace

Basically, I have multiple local packages in one workspace, some of which export proc-macros from their respective package conveniently named macros.

While I could rename every package to something unique to solve this issue now, it doesn't really seem like a long-term solution, as to avoid name collisions in my workspace I would have to name each of those crates something like: macros_0, macros_1, ..., and then keep track of what index I used most recently manually.

Simplified workspace structure:

├── package_1 
├── package_2
│   └── macros // <- name collision
└── package_3
    └── macros // <- name collision

So, is there a more elegant solution to this problem?

You could use names like package_2_macros and package_3_macros for the proc-macros of package_2 cq package_3. This matches what many crates using proc-macros do.

Makes sense. I guess I was hoping there was some kind of Cargo.toml section which could tell cargo to treat sub-crates of a package in some kind of special way so that the collision problem wouldn't occur. But that solution seems good enough. Thank you!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.