rust-num / num-derive

Procedural macros to derive numeric traits in Rust
Apache License 2.0
166 stars 24 forks source link

Cannot reexport `num-derive` proc_macros #34

Closed jean-airoldie closed 4 years ago

jean-airoldie commented 4 years ago

Since the proc_macro implementation explicity declares an extern num_traits crate, any crate that wants to use it must also depend on num-traits.

https://github.com/rust-num/num-derive/blob/1b361d7af828467aa9a1d80d609793f0a312aae5/src/lib.rs#L80

This can be a problem in case a crate reexport a num-derive proc macros because it forces the user to also depend on num-traits otherwise it produces: error[E0463]: can't find crate for_num_traits`.

Would it be possible to add a feature flag that disable this behavior? Specifically it would be the user's responsability to make sure that the num-traits crate is in scope.

jean-airoldie commented 4 years ago

A better solution would be to provide a proc_macro helper attribute that allows the user to specify an explicit import identifier. If no such helper if present, the proc_macro would default to the current behavior.