Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use re-exported Key derive macro #43

Open
TheDan64 opened this issue Nov 12, 2022 · 2 comments
Open

Can't use re-exported Key derive macro #43

TheDan64 opened this issue Nov 12, 2022 · 2 comments
Labels
question Further information is requested

Comments

@TheDan64
Copy link

Not sure if this is an issue with rustc/cargo or if there's a way for fixed_map to solve it, but I'm writing a library that uses a fixed map as input. So I want to re-export the Key derive macro for users of my library to use on their own types:

pub use fixed_map::Key;

This works fine and compiles in the library, however, when trying to use the Key derive type in a crate using my library:

63 | #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Key)]
   |                                                                    ^^^ could not find `fixed_map` in the list of imported crates
51 | #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Key)]
   |                                                                    ^^^ not found in `fixed_map::map`

From the sound of it, the error is because the crate using my library doesn't directly use fixed_map as one of it's dependencies? But it seems kinda unfortunate that to use my lib, they also have to explicitly add fixed_map as a dep...

Any ideas if it's possible to get this to work?

@pitaj
Copy link
Collaborator

pitaj commented Nov 13, 2022

I believe this is currently an unsolved problem in the Rust ecosystem.

@udoprog
Copy link
Owner

udoprog commented Nov 13, 2022

Yeah, two options:

  • We add a crate option to the macro, but then users would have to specify that to some point where you re-export internals.
  • You write a proc-macro that reuses the internals but is configured to use your crate re-export by default.

None of which are great I'm afraid!

@udoprog udoprog added the question Further information is requested label Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants