-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't
Description
Summary
My xorsum
crate has a fn to convert a byte-vector to its hex-encoded form, it repeatedly calls format!
appending its result to a String
, but Clippy didn't show a warning
Lint Name
format_push_string
Reproducer
I tried this code:
#![warn(clippy::format_push_string)]
pub fn u8vec_to_hex(vector: &Vec<u8>, upper: bool) -> String {
let mut hex = String::with_capacity(vector.len() * 2);
for byte in vector {
hex += &(if upper {
format!("{byte:02X}")
} else {
format!("{byte:02x}")
});
}
hex
}
I expected to see this happen: Warning
Instead, this happened: Nothing
Version
rustc 1.63.0 (4b91a6ea7 2022-08-08)
binary: rustc
commit-hash: 4b91a6ea7258a947e59c6522cd5898e7c0a6a88f
commit-date: 2022-08-08
host: x86_64-unknown-linux-gnu
release: 1.63.0
LLVM version: 14.0.5
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't