Merge rust-bitcoin/rust-bitcoin#7129: primitives: Tidy docs
What changed, and why it matters
This commit is a documentation-only cleanup. It fixes typos, adds missing punctuation and blank lines, updates a panic description, removes a stale comment about old Rust atomics, and adds a missing SPDX license header. No executable code behavior was changed, so there is no security impact.
No security action required. Treat as routine documentation maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The merge commit d15199497153c94a9066fd217fa639a95b140520 merges PR #7129, which is explicitly described as ‘Docs only changes.’ The diff shows only comment/docstring edits in primitives/src/script/borrowed.rs, mod.rs, owned.rs, primitives/src/transaction.rs, primitives/src/witness.rs, primitives/src/witness_version.rs, and a license header addition in primitives/tests/block.rs. No logic, API, or control-flow changes are present.
Changed components
primitives/src/script/borrowed.rsprimitives/src/script/mod.rsprimitives/src/script/owned.rsprimitives/src/transaction.rsprimitives/src/witness.rsprimitives/src/witness_version.rsprimitives/tests/block.rsInspect captured patch +17 / −13
### primitives/src/script/borrowed.rs
@@ -206,7 +206,7 @@ impl<T> Script<T> {
#[deprecated(since = "1.0.0-rc.0", note = "use `format!(\"{var:x}\")` instead")]
pub fn to_hex(&self) -> alloc::string::String { alloc::format!("{:x}", self) }
- /// Constructs a new script builder
+ /// Constructs a new script builder.
pub fn builder() -> Builder<T> { Builder::new() }
/// Returns witness version of the script, if any.
@@ -312,7 +312,7 @@ impl ScriptPubKey {
}
impl WitnessScript {
- /// Returns 256-bit hash of the script for P2WSH outputs.
+ /// Returns the 256-bit hash of the script for P2WSH outputs.
///
/// # Errors
///
@@ -324,7 +324,7 @@ impl WitnessScript {
}
impl<T: ScriptHashableTag> Script<T> {
- /// Returns 160-bit hash of the script for P2SH outputs.
+ /// Returns the 160-bit hash of the script for P2SH outputs.
///
/// # Errors
///
### primitives/src/script/mod.rs
@@ -258,6 +258,7 @@ impl AsRef<ScriptCode> for ScriptPubKeyBuf {
script_pub_key.as_ref()
}
}
+
impl From<WitnessScriptBuf> for SignetBlockScriptBuf {
#[inline]
fn from(buf: WitnessScriptBuf) -> Self { Self::from_bytes(buf.into_bytes()) }
@@ -310,7 +311,6 @@ impl<'a, T> From<&'a Script<T>> for Cow<'a, Script<T>> {
fn from(value: &'a Script<T>) -> Self { Cow::Borrowed(value) }
}
-/// Note: This will fail to compile on old Rust for targets that don't support atomics
#[cfg(target_has_atomic = "ptr")]
impl<'a, T> From<&'a Script<T>> for Arc<Script<T>> {
#[inline]
### primitives/src/script/owned.rs
@@ -177,7 +177,7 @@ impl<T> ScriptBuf<T> {
#[deprecated(since = "1.0.0-rc.0", note = "use `format!(\"{var:x}\")` instead")]
pub fn to_hex(&self) -> alloc::string::String { alloc::format!("{:x}", self) }
- /// Constructs a new script builder
+ /// Constructs a new script builder.
pub fn builder() -> Builder<T> { Builder::new() }
/// Adds a single opcode to the script.
@@ -272,7 +272,7 @@ impl<T> ScriptBuf<T> {
ScriptBufAsVec(self, vec)
}
- /// Pushes the slice without reserving
+ /// Pushes the slice without reserving.
fn push_slice_no_opt(&mut self, data: &PushBytes) {
let mut this = self.as_byte_vec();
// Start with a PUSH opcode
### primitives/src/transaction.rs
@@ -1540,7 +1540,7 @@ pub mod error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { Some(&self.0) }
}
- /// Error while decoding an [`OutPoint`].
+ /// An error consensus decoding an [`OutPoint`].
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct OutPointDecoderError(pub(super) encoding::UnexpectedEofError);
### primitives/src/witness.rs
@@ -133,13 +133,14 @@ impl Witness {
Self { content: Vec::new(), witness_elements: 0, indices_start: 0 }
}
- /// Constructs a new [`Witness`] object from a slice of bytes slices where each slice is a witness item.
+ /// Constructs a new [`Witness`] object from a slice of byte slices where each slice is a witness
+ /// item.
///
/// # Panics
///
- /// Panics if the starting offset of the last element within encoded bytes exceeds `u32::MAX`. When
- /// the sum of the lengths of the elements before the last one, including their length prefixes,
- /// is larger than that maximum.
+ /// Panics if the starting offset of the last element within the encoded bytes exceeds
+ /// `u32::MAX`, i.e., if the sum of the lengths of the elements before the last one, including
+ /// their length prefixes, is larger than that maximum.
///
/// # Examples
///
@@ -356,7 +357,7 @@ impl Witness {
}
}
-/// Correctness Requirements: value must always fit within u32
+/// Correctness requirements: `value` must always fit within a `u32`.
#[inline]
#[track_caller]
fn encode_cursor(bytes: &mut [u8], start_of_indices: usize, index: usize, value: usize) {
@@ -931,7 +932,7 @@ impl<'a> Arbitrary<'a> for Witness {
}
}
-/// Cast a decoded length prefix to a `usize`.
+/// Casts a decoded length prefix to a `usize`.
///
/// This function is basically just defensive. For all sane use cases the length prefix should be
/// less than `MAX_VEC_SIZE` (on a 32-bit machine). If the value is bigger that `u16::MAX` and we
### primitives/src/witness_version.rs
@@ -271,6 +271,7 @@ pub mod error {
}
}
}
+
/// Error attempting to create a [`WitnessVersion`] from an integer.
///
/// [`WitnessVersion`]: super::WitnessVersion
### primitives/tests/block.rs
@@ -1,3 +1,5 @@
+// SPDX-License-Identifier: CC0-1.0
+
#![cfg(feature = "alloc")]
use bitcoin_primitives::block::{Block, Unchecked};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.