Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format_push_string doesn't trigger "indirectly" #9493

Closed
Rudxain opened this issue Sep 18, 2022 · 0 comments · Fixed by #11021
Closed

format_push_string doesn't trigger "indirectly" #9493

Rudxain opened this issue Sep 18, 2022 · 0 comments · Fixed by #11021
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't

Comments

@Rudxain
Copy link

Rudxain commented Sep 18, 2022

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
@Rudxain Rudxain added C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't labels Sep 18, 2022
@bors bors closed this as completed in 1b4c423 Jun 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant