num-derive
num-derive copied to clipboard
Macros are unhygenic
When using this alongside the xlang_abi crate, the following error is thrown:
error[E0053]: method `from_u64` has an incompatible type for trait
--> modules/elf/src/lib.rs:13:10
|
13 | #[derive(FromPrimitive, ToPrimitive)]
| ^^^^^^^^^^^^^
| |
| expected enum `std::option::Option`, found enum `xlang_abi::option::Option`
| help: change the output type to match the trait: `std::option::Option<ProgramHeaderType>`
|
= note: expected fn pointer `fn(_) -> std::option::Option<ProgramHeaderType>`
found fn pointer `fn(_) -> xlang_abi::option::Option<ProgramHeaderType>`
= note: this error originates in the derive macro `FromPrimitive` (in Nightly builds, run with -Z macro-backtrace for more info)
This can be solved by specifying core::option::Option in any place where Option is used.
Ugh, I see what they're going for, but it still feels unfortunate to overlap prelude names.
The full path should be ::core::option::Option to fully distinguish the crate from a local module named core.