From d2ca03c3683d7a03ee241df51d1d5bc6ead5b359 Mon Sep 17 00:00:00 2001 From: mehmetkr-31 Date: Tue, 1 Sep 2026 16:39:26 +0300 Subject: [PATCH] docs(types): record that the codec macros must precede the mod declarations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `network` and `wal` reach `impl_versioned_codec!` and `impl_versioned_codec_with_legacy_fallback!` through textual scope — there is no path import and no `pub(crate) use` re-export. Hoisting the `pub mod` block above the macros, or alphabetising the file, breaks all 11 invocation sites with `cannot find macro`, and nothing at those sites hints at the dependency. Comments only; no behaviour change. --- crates/types/src/codec/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/types/src/codec/mod.rs b/crates/types/src/codec/mod.rs index 6487896c..1cffc905 100644 --- a/crates/types/src/codec/mod.rs +++ b/crates/types/src/codec/mod.rs @@ -26,6 +26,11 @@ pub use malachitebft_codec::{Codec, HasEncodedLen}; /// - `$ty`: The message type to encode/decode /// - `$version_ty`: The version enum type /// - `$version_val`: The specific version value to use +/// +/// Must stay above the `pub mod` declarations at the bottom of this file: +/// `network` reaches this macro through textual scope, not through a path, so +/// moving the module declarations above it — or moving this below them — +/// breaks all 8 invocation sites with `cannot find macro`. macro_rules! impl_versioned_codec { ($codec_ty:ty, $ty:ty, $version_ty:ty, $version_val:expr) => { impl malachitebft_codec::Codec<$ty> for $codec_ty { @@ -75,6 +80,9 @@ macro_rules! impl_versioned_codec { /// This is only for persisted data formats that predate version bytes, such as /// the WAL. Networked types are already versioned and should use /// `impl_versioned_codec!` instead. +/// +/// Same ordering constraint as `impl_versioned_codec!`: `wal` reaches this +/// through textual scope, so it must stay above the `pub mod` declarations. macro_rules! impl_versioned_codec_with_legacy_fallback { ($codec_ty:ty, $ty:ty, $version_ty:ty, $version_val:expr) => { impl malachitebft_codec::Codec<$ty> for $codec_ty {