dtolnay / linkme

Safe cross-platform linker shenanigans
Apache License 2.0
646 stars 41 forks source link

Avoid polluting the type namespace #43

Closed rMazeiks closed 2 years ago

rMazeiks commented 3 years ago

First of all, my changes require using macro_rules! in a procedural macro, so it won't work for versions of Rust older than 1.40. Of course I will 100% understand if this is an issue (in fact you did have a test for 1.36 which I bumped) – in that case feel free to just reject this PR.

Currently, [distributed_slice] defines a "dummy" Enum (surely for good reasons that I don't understand as a Rust beginner). For a personal project of mine, this was causing issues because I needed to define types with the same name as the distributed slice, but the type namespace was already used.

I managed to refactor things a bit so that the dummy macro is not used. These changes also simplify things a bit, avoiding a confusing (for me) step of creating an intermediary Enum and then parsing it in another macro.

This code meets my personal project's requirements, so I'll be using it anyway. Just thought I'd open a PR in case you find this useful. Feedback and suggestions are always welcome!