Use stacked attributes over #[cfg(all(...))]
What changed, and why it matters
This commit is a purely cosmetic code-style change. It rewrites some Rust feature-gate conditions from one allowed syntax to another preferred syntax, with no change to which features enable which code. There is no security relevance.
No security action needed; treat as normal style/refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch replaces #[cfg(all(feature = “hex”, feature = “alloc”))] with stacked #[cfg(feature = “hex”)] + #[cfg(feature = “alloc”)] attributes in two primitives source files. In Rust, stacked #[cfg] attributes are logically ANDed, so the compiled conditional behavior is identical. No logic, API, or dependency changes are introduced.
Changed components
primitives/src/block.rsprimitives/src/transaction.rsInspect captured patch +8 / −4
diff --git a/primitives/src/block.rs b/primitives/src/block.rs
index 771716cc..d2bb80c4 100644
--- a/primitives/src/block.rs
+++ b/primitives/src/block.rs
@@ -36,7 +36,8 @@ use crate::{Transaction, Wtxid};
pub use units::block::{BlockHeight, BlockHeightDecoder, BlockHeightEncoder, BlockHeightInterval, BlockMtp, BlockMtpInterval};
#[rustfmt::skip] // Keep public re-exports separate.
-#[cfg(all(feature = "hex", feature = "alloc"))]
+#[cfg(feature = "hex")]
+#[cfg(feature = "alloc")]
#[doc(no_inline)]
pub use self::error::ParseBlockError;
#[cfg(feature = "hex")]
diff --git a/primitives/src/transaction.rs b/primitives/src/transaction.rs
index 54ffd823..bd0eddbc 100644
--- a/primitives/src/transaction.rs
+++ b/primitives/src/transaction.rs
@@ -52,7 +52,8 @@ use crate::witness::{WitnessDecoder, WitnessEncoder};
use crate::{absolute, Amount, ScriptPubKeyBuf, ScriptSigBuf, Sequence, Weight, Witness};
#[rustfmt::skip] // Keep public re-exports separate.
-#[cfg(all(feature = "hex", feature = "alloc"))]
+#[cfg(feature = "hex")]
+#[cfg(feature = "alloc")]
#[doc(no_inline)]
pub use self::error::{ParseTransactionError, ParseOutPointError};
#[doc(no_inline)]
@@ -1273,9 +1274,11 @@ pub mod error {
#[cfg(feature = "alloc")]
use super::OutPoint;
- #[cfg(all(feature = "hex", feature = "alloc"))]
+ #[cfg(feature = "hex")]
+ #[cfg(feature = "alloc")]
use super::{parse_int, Transaction};
- #[cfg(all(feature = "hex", feature = "alloc"))]
+ #[cfg(feature = "hex")]
+ #[cfg(feature = "alloc")]
use crate::hex_codec::ParsePrimitiveError;
#[cfg(feature = "alloc")]
use crate::locktime::absolute::LockTimeDecoderError;
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.