Commit message · Andrew PoelstraMerge rust-bitcoin/rust-bitcoin#7165: Remove the `_export` module from units and primitives
d45f6b05ee6ba9a887459748f5e5ba226d45f1a1 primitives: remove _export module (satsfy (Renato Britto))
debe7769b7e69ffaeb7a5e7976895e97eb17e440 units: remove _export module (satsfy (Renato Britto))
Pull request description:
Part of https://github.com/rust-bitcoin/rust-bitcoin/issues/4130.
This is a breaking change!
A macro body is pasted into the caller, so `core::fmt::Display` inside a macro means whatever `core` is at the call site, not ours crate's `core` (https://doc.rust-lang.org/reference/macros-by-example.html#hygiene). When the caller is another crate, that can go fail things we cannot test for, so it used to be that exported macros write `$crate::_export::_core` to force our own `core`.
However, units removed its last exported macros in https://github.com/rust-bitcoin/rust-bitcoin/pull/4886 and primitives never exported any, so neither module serves a macro anymore. In fact, I don't think we should ever put back a macro in them. So i removed that. I also confirmed that nowhere else is it applicable to remove this or add, by checking which crates have a `#[macro_export]` attribute.
I also searched public Rust code for `units::_export` and `primitives::_export`, nothing was found, so this PR has not broken any public user we know of, but it can break a private repo somewhere. But `hashes::_export::_core` does leak downstream though (e.g. [rust-lightning](https://github.com/lightningdevkit/rust-lightning/blob/main/lightning/src/onion_message/messenger.rs#L148), [mintlayer](https://github.com/mintlayer/bitcoin-rpc-api/blob/master/src/lib.rs#L36)), which shows the risk of keeping such a module: because it re-exports all of `core`, an IDE, for example, offers auto import of `bitcoin::hashes::_export::_core::time::Duration` next to `core::time::Duration`, users may pick in a moment of inattention, and every later move of the hidden module breaks their build.
This PR is not a technically a semver break, but our fix drops that prefix downstream users could, in theory, by relying on, which would break their compilation. If we ever remove it from hashes is would be a breaking change.
This change is also applicable to internals, but I can see a future in which it exports macros, and may potentially be moved to rust-bitcoin-maintainer-tools, so leave that as a follow up.
ACKs for top commit:
tcharding:
ACK d45f6b05ee6ba9a887459748f5e5ba226d45f1a1
apoelstra:
ACK d45f6b05ee6ba9a887459748f5e5ba226d45f1a1; successfully ran local tests
Tree-SHA512: 8745cea31121c24aeaa534316448f917fb8cbfc2fc0ab5cd2c62467f7fc0b97b739a861f9117bcf38f333a865b04e10056b0cd4c2d8bd3aac89c0af21014471f
100/100 · StrongMessage clarity
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
Why it was queuedmerge-commit duplicate discount