Skip to content

Commit 6be537f

Browse files
authored
Fix clippy warning in qpy module (#15951)
This commit fixes a clippy error in the qpy module when running clippy with the latest stable rust release. In #15698 we denied the use of unwrap() or expect() to minimize the chance of the qpy module panicking. We shouldn't ever panic in the qpy module because anything that causes an error condition was caused by malformed input and should be reported to the user and be handleable and not cause a hard crash. However, the clippy check apparently isn't as exhaustive on our MSRV of 1.85 and it didn't catch the usage of unwrap() in one place. This is causing a failure when you do run clippy with a newer version of Rust. This commit fixes this error by throwing away the error condition. In this case the call to the `write!()` macro is infallible since it's just the string format which is infallible unless the underlying write fails [1]. But since we're writing to a `String` object that we just allocated in this case there is never a way or this to fail short of a hardware failure. So to solve the clippy error and prevent it from becoming a CI failure in the future this commit opts to just discard the error without using it. [1] https://doc.rust-lang.org/std/fmt/struct.Error.html
1 parent 12bb3ef commit 6be537f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

crates/qpy/src/bytes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl Bytes {
3232
self.0
3333
.iter()
3434
.fold(String::with_capacity(self.0.len() * 2), |mut acc, b| {
35-
write!(&mut acc, "{:02x}", b).unwrap();
35+
let _ = write!(&mut acc, "{:02x}", b);
3636
acc
3737
})
3838
}

0 commit comments

Comments
 (0)