What changed, and why it matters
This commit fixes compiler lint warnings in the rust-bitcoin library's script-building code. It adds #[must_use] annotations to builder methods and changes a numeric literal format for readability. There is no security-relevant behavior change.
No security action required. Treat as a normal code-quality/lint cleanup commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds #[must_use] to three Builder
Changed components
primitives/src/script/builder.rsprimitives/src/script/owned.rsInspect captured patch +4 / −1
diff --git a/primitives/src/script/builder.rs b/primitives/src/script/builder.rs
index 8703b9e6..f903a2e5 100644
--- a/primitives/src/script/builder.rs
+++ b/primitives/src/script/builder.rs
@@ -31,6 +31,7 @@ impl<T> Builder<T> {
/// If your pushes should be interpreted as numbers, ensure your input does
/// not have any leading zeros. In particular, the number 0 should be encoded
/// as an empty string rather than as a single 0 byte.
+ #[must_use]
pub fn push_slice<D: AsRef<PushBytes>>(mut self, data: D) -> Self {
self.0.push_slice(data);
self
@@ -41,12 +42,14 @@ impl<T> Builder<T> {
/// Standardness rules require push minimality according to [CheckMinimalPush] of core.
///
/// [CheckMinimalPush]: <https://github.com/bitcoin/bitcoin/blob/99a4ddf5ab1b3e514d08b90ad8565827fda7b63b/src/script/script.cpp#L366>
+ #[must_use]
pub fn push_slice_non_minimal<D: AsRef<PushBytes>>(mut self, data: D) -> Self {
self.0.push_slice_non_minimal(data);
self
}
/// Adds a single opcode to the script.
+ #[must_use]
pub fn push_opcode(mut self, data: Opcode) -> Self {
self.0.push_opcode(data);
self
diff --git a/primitives/src/script/owned.rs b/primitives/src/script/owned.rs
index 4236323c..81e51883 100644
--- a/primitives/src/script/owned.rs
+++ b/primitives/src/script/owned.rs
@@ -250,7 +250,7 @@ impl<T> ScriptBuf<T> {
this.push((n % 0x100) as u8);
this.push(((n / 0x100) % 0x100) as u8);
this.push(((n / 0x10000) % 0x100) as u8);
- this.push((n / 0x1000000) as u8);
+ this.push((n / 0x0100_0000) as u8);
}
}
// Then push the raw bytes
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.