What changed, and why it matters
This commit only fixes minor style warnings reported by the Clippy linter. It changes how a file path is printed in a build script, adds a missing semicolon in a hashing function, removes an unnecessary semicolon after an if block, and replaces one numeric type cast with a safer conversion in a unit test. None of these changes fix a security vulnerability.
No security action needed. Treat as routine code-quality maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff addresses four pedantic Clippy lints in the rust-bitcoin internals crate: (1) uses Path::display() instead of Debug formatting for the rustc executable path in build.rs; (2) adds a trailing semicolon in ArrayVec’s hash method; (3) removes an extraneous semicolon after an if block in read_push_data_len; (4) changes want as usize to usize::try_from(want).unwrap() in a test. These are cosmetic/code-quality changes with no functional security impact.
Changed components
internals/build.rsinternals/src/array_vec.rsinternals/src/script.rsInspect captured patch +8 / −8
diff --git a/internals/build.rs b/internals/build.rs
index 05e9fa98..725526c0 100644
--- a/internals/build.rs
+++ b/internals/build.rs
@@ -8,11 +8,11 @@ use std::io;
fn main() {
let rustc = std::env::var_os("RUSTC");
let rustc = rustc.as_ref().map_or_else(|| "rustc".as_ref(), std::path::Path::new);
- let output = std::process::Command::new(rustc)
- .arg("--version")
- .output()
- .unwrap_or_else(|error| panic!("failed to run `{:?} --version`: {:?}", rustc, error));
- assert!(output.status.success(), "{:?} -- version returned non-zero exit code", rustc);
+ let output =
+ std::process::Command::new(rustc).arg("--version").output().unwrap_or_else(|error| {
+ panic!("failed to run `{} --version`: {:?}", rustc.display(), error)
+ });
+ assert!(output.status.success(), "{} -- version returned non-zero exit code", rustc.display());
let stdout = String::from_utf8(output.stdout).expect("rustc produced non-UTF-8 output");
let version_prefix = "rustc ";
assert!(stdout.starts_with(version_prefix), "unexpected rustc output: {}", stdout);
diff --git a/internals/src/array_vec.rs b/internals/src/array_vec.rs
index 0ea6001d..5f5babf5 100644
--- a/internals/src/array_vec.rs
+++ b/internals/src/array_vec.rs
@@ -174,7 +174,7 @@ impl<T: Copy + fmt::Debug, const CAP: usize> fmt::Debug for ArrayVec<T, CAP> {
}
impl<T: Copy + core::hash::Hash, const CAP: usize> core::hash::Hash for ArrayVec<T, CAP> {
- fn hash<H: core::hash::Hasher>(&self, state: &mut H) { core::hash::Hash::hash(&**self, state) }
+ fn hash<H: core::hash::Hasher>(&self, state: &mut H) { core::hash::Hash::hash(&**self, state); }
}
#[cfg(test)]
diff --git a/internals/src/script.rs b/internals/src/script.rs
index e95e875e..10bab350 100644
--- a/internals/src/script.rs
+++ b/internals/src/script.rs
@@ -21,7 +21,7 @@ pub fn read_push_data_len(
if data.len() < size {
return Err(EarlyEndOfScriptError);
- };
+ }
let mut ret = 0;
for (i, item) in data.take(size).enumerate() {
@@ -72,6 +72,6 @@ mod tests {
let bytes = [0x01];
let want = 0x01;
let got = read_push_data_len(&mut bytes.iter(), PushDataLenLen::One).unwrap();
- assert_eq!(got, want as usize);
+ assert_eq!(got, usize::try_from(want).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.