mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-27 00:21:15 -03:00
clippy: fix format_push_string lint
https://rust-lang.github.io/rust-clippy/master/index.html#format_push_string Closes #12338
This commit is contained in:
committed by
Johannes Altmanninger
parent
d35edcf5fa
commit
c99c84558f
@@ -193,6 +193,7 @@ rustdoc.private_intra_doc_links = "allow"
|
||||
[workspace.lints.clippy]
|
||||
assigning_clones = "warn"
|
||||
cloned_instead_of_copied = "warn"
|
||||
format_push_string = "warn"
|
||||
implicit_clone = "warn"
|
||||
len_without_is_empty = "allow" # we're not a library crate
|
||||
let_and_return = "allow"
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
use crate::wutil::fish_iswalnum;
|
||||
use fish_wcstringutil::count_preceding_backslashes;
|
||||
use fish_wgetopt::{ArgType, WGetopter, WOption, wopt};
|
||||
use std::fmt::Write as _;
|
||||
|
||||
/// Note: this got somewhat more complicated after introducing the new AST, because that AST no
|
||||
/// longer encodes detailed lexical information (e.g. every newline). This feels more complex
|
||||
@@ -1286,14 +1287,16 @@ struct TokenRange {
|
||||
}
|
||||
|
||||
// Now render these to a string.
|
||||
let mut result = String::new();
|
||||
let mut result = String::with_capacity(token_ranges.len() * 32);
|
||||
for range in token_ranges {
|
||||
result += &format!(
|
||||
"{},{},{}\n",
|
||||
writeln!(
|
||||
result,
|
||||
"{},{},{}",
|
||||
range.start,
|
||||
range.end,
|
||||
highlight_role_to_string(range.role)
|
||||
);
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
result.into_bytes()
|
||||
}
|
||||
|
||||
@@ -1385,6 +1385,7 @@ mod tests {
|
||||
use fish_util::get_seeded_rng;
|
||||
use fish_widestring::{ENCODE_DIRECT_BASE, L, WString, wstr};
|
||||
use rand::{Rng, RngCore};
|
||||
use std::fmt::Write as _;
|
||||
|
||||
#[test]
|
||||
fn test_escape_string() {
|
||||
@@ -1525,9 +1526,9 @@ fn test_escape_no_printables() {
|
||||
|
||||
/// Helper to convert a narrow string to a sequence of hex digits.
|
||||
fn bytes2hex(input: &[u8]) -> String {
|
||||
let mut output = "".to_string();
|
||||
let mut output = String::with_capacity(input.len() * 5);
|
||||
for byte in input {
|
||||
output += &format!("0x{:2X} ", *byte);
|
||||
write!(output, "0x{:2X} ", *byte).unwrap();
|
||||
}
|
||||
output
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user