Merge rust-bitcoin/rust-bitcoin#6850: Use stacked attributes for feature conjunctions
What changed, and why it matters
This commit is a code-style cleanup with no security impact. It changes how Rust conditional-compilation attributes are written, replacing combined `#[cfg(all(...))]` checks with stacked `#[cfg(...)]` attributes, following the project's own documented style policy. No program behavior changes.
No security action required. Treat as normal maintenance/style cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors #[cfg(all(feature = "alloc", feature = "hex"))] into two stacked #[cfg(feature = "alloc")] / #[cfg(feature = "hex")] attributes in test and documentation code. In Rust, stacked #[cfg] attributes are semantically equivalent to cfg(all(...)), so compilation conditions and runtime behavior are unchanged. The change is purely stylistic, aligning with rust-bitcoin’s policy.md guidance.
Changed components
consensus_encoding/tests/decode.rsconsensus_encoding/tests/encode.rsprimitives/src/transaction.rsInspect captured patch +14 / −7
### consensus_encoding/tests/decode.rs
@@ -302,7 +302,8 @@ fn decode_from_hex_test() {
}
#[test]
-#[cfg(all(feature = "hex", feature = "alloc"))]
+#[cfg(feature = "alloc")]
+#[cfg(feature = "hex")]
fn decode_from_hex_larger_than_internal_buffer() {
const COUNT: usize = 1100;
### consensus_encoding/tests/encode.rs
@@ -92,7 +92,8 @@ fn encode_vec_empty_data() {
}
#[test]
-#[cfg(all(feature = "alloc", feature = "hex"))]
+#[cfg(feature = "alloc")]
+#[cfg(feature = "hex")]
fn encode_hex() {
let data = TestData(0xDEAD_BEEF);
let hex = bitcoin_consensus_encoding::encode_to_hex(&data, hex::Case::Lower);
@@ -102,7 +103,8 @@ fn encode_hex() {
}
#[test]
-#[cfg(all(feature = "alloc", feature = "hex"))]
+#[cfg(feature = "alloc")]
+#[cfg(feature = "hex")]
fn encode_hex_empty_data() {
let data = EmptyData;
let hex = bitcoin_consensus_encoding::encode_to_hex(&data, hex::Case::Lower);
@@ -558,7 +560,8 @@ fn check_encoder_detects_error_byte_offset() {
}
#[test]
-#[cfg(all(feature = "alloc", feature = "hex"))]
+#[cfg(feature = "alloc")]
+#[cfg(feature = "hex")]
fn drain_hex_multi_chunk() {
let enc1 = ArrayEncoder::without_length_prefix([0xDE_u8, 0xAD]);
let enc2 = ArrayEncoder::without_length_prefix([0xBE_u8, 0xEF]);
### primitives/src/transaction.rs
@@ -13,9 +13,11 @@
//! # Examples
//!
//! ```rust
-//! # #[cfg(all(feature = "alloc", feature = "hex"))]
+//! # #[cfg(feature = "alloc")]
+//! # #[cfg(feature = "hex")]
//! # type Error = encoding::FromHexError<bitcoin_primitives::transaction::TransactionDecoderError>;
-//! # #[cfg(all(feature = "alloc", feature = "hex"))]
+//! # #[cfg(feature = "alloc")]
+//! # #[cfg(feature = "hex")]
//! # fn example() -> Result<(), Error> {
//! use bitcoin_primitives::transaction::Version;
//! use bitcoin_primitives::Transaction;
@@ -49,7 +51,8 @@
//! );
//! # Ok(())
//! # }
-//! # #[cfg(all(feature = "alloc", feature = "hex"))]
+//! # #[cfg(feature = "alloc")]
+//! # #[cfg(feature = "hex")]
//! # example().unwrap();
//! ```
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.