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

Fixing exporting macros required to get `hash_newtype` macro to work correctly #63

Open
wants to merge 2 commits into
base: master
from

Conversation

@dr-orlovsky
Copy link

commented Sep 25, 2019

While I was working on implementing rust-bitcoin/rust-bitcoin#284 I've found that the new hash_newtype can't be used outside of bitcoin_hashes project due to fact that macros used by it are not exported. This PR fixes the problem for most of such macros.

Nevertheless, I am still not able to run https://github.com/pandoracore/rust-bitcoin/blob/hashtypes/src/lib.rs#L67 due to problems with serde crate access from inside hash_newtype macro. Any suggestions?

@dr-orlovsky dr-orlovsky changed the title Fixing exporting macros required to get `hash_newtype` macro to work correctly [WIP] Fixing exporting macros required to get `hash_newtype` macro to work correctly Sep 25, 2019
@thomaseizinger

This comment has been minimized.

Copy link

commented Sep 25, 2019

You should be able to solve that by re-exporting the whole serde crate from bitcoin_hashes through pub extern crate serde and using it inside the macro as $crate::serde.

@dr-orlovsky dr-orlovsky force-pushed the pandoracore:hashnewtype-fix branch from 63647b2 to 47dbcd4 Sep 26, 2019
@dr-orlovsky

This comment has been minimized.

Copy link
Author

commented Sep 26, 2019

Thank you, @thomaseizinger, that has worked

@dr-orlovsky dr-orlovsky changed the title [WIP] Fixing exporting macros required to get `hash_newtype` macro to work correctly Fixing exporting macros required to get `hash_newtype` macro to work correctly Sep 26, 2019
@dr-orlovsky

This comment has been minimized.

Copy link
Author

commented Sep 26, 2019

Some builds are failed due to #64

This PR fixing the problem has to be merged first before getting this PR merged

@dr-orlovsky dr-orlovsky force-pushed the pandoracore:hashnewtype-fix branch from 47dbcd4 to 262a0fc Sep 26, 2019
@dr-orlovsky dr-orlovsky force-pushed the pandoracore:hashnewtype-fix branch from 262a0fc to e99d6da Sep 26, 2019
@stevenroose

This comment has been minimized.

Copy link
Collaborator

commented Sep 27, 2019

One possible downside IMO is that it seems also our internal macros are exported. Does anyone know if it's possible to just export certain macros?

Or is that not possible because that macro uses all the internal ones?

@dr-orlovsky

This comment has been minimized.

Copy link
Author

commented Oct 1, 2019

Basically only macros with #[macro_export] are exported, so it's not that we export internal macros. However, I had to do all previously internal macros used by hash_newtype macro to be exportable, otherwise hash_newtype can't be exportable itself.

So not all internal macros are exported, but the list of the exported macros has grown

src/lib.rs Outdated
#[cfg(any(test, feature="std"))] extern crate core;
#[cfg(feature="serde")] extern crate serde;
#[cfg(all(test,feature="serde"))] extern crate serde_test;
#[cfg(any(test, feature="std"))] pub extern crate core;

This comment has been minimized.

Copy link
@stevenroose

stevenroose Oct 8, 2019

Collaborator

Does it make sense to export core? It's not a third party dep, right?

This comment has been minimized.

Copy link
@dr-orlovsky

dr-orlovsky Oct 13, 2019

Author

You are right, it can be removed. Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.