Fix some new clippy warnings (#12645)

This commit is contained in:
Zhang Wen
2026-06-06 13:52:15 +08:00
committed by GitHub
parent 7cfc74e47f
commit 7f791b9cd7
5 changed files with 18 additions and 19 deletions
+7 -7
View File
@@ -244,13 +244,13 @@ fn parse_delimiters(delimiters: &OsString) -> UResult<Box<[Box<[u8]>]>> {
}
match bytes[i] {
b'0' => vec.push(Box::new([])),
b'\\' => vec.push(Box::new([b'\\'])),
b'n' => vec.push(Box::new([b'\n'])),
b't' => vec.push(Box::new([b'\t'])),
b'b' => vec.push(Box::new([b'\x08'])),
b'f' => vec.push(Box::new([b'\x0C'])),
b'r' => vec.push(Box::new([b'\r'])),
b'v' => vec.push(Box::new([b'\x0B'])),
b'\\' => vec.push(Box::new(*b"\\")),
b'n' => vec.push(Box::new(*b"\n")),
b't' => vec.push(Box::new(*b"\t")),
b'b' => vec.push(Box::new(*b"\x08")),
b'f' => vec.push(Box::new(*b"\x0C")),
b'r' => vec.push(Box::new(*b"\r")),
b'v' => vec.push(Box::new(*b"\x0B")),
_ => {
// Unknown escape: strip backslash, use the following character(s)
let remaining = &bytes[i..];
+6 -6
View File
@@ -63,12 +63,12 @@ const PATTERNS: [Pattern; 22] = [
Pattern::Single(b'\xFF'),
Pattern::Single(b'\x55'),
Pattern::Single(b'\xAA'),
Pattern::Multi([b'\x24', b'\x92', b'\x49']),
Pattern::Multi([b'\x49', b'\x24', b'\x92']),
Pattern::Multi([b'\x6D', b'\xB6', b'\xDB']),
Pattern::Multi([b'\x92', b'\x49', b'\x24']),
Pattern::Multi([b'\xB6', b'\xDB', b'\x6D']),
Pattern::Multi([b'\xDB', b'\x6D', b'\xB6']),
Pattern::Multi(*b"\x24\x92\x49"),
Pattern::Multi(*b"\x49\x24\x92"),
Pattern::Multi(*b"\x6D\xB6\xDB"),
Pattern::Multi(*b"\x92\x49\x24"),
Pattern::Multi(*b"\xB6\xDB\x6D"),
Pattern::Multi(*b"\xDB\x6D\xB6"),
Pattern::Single(b'\x11'),
Pattern::Single(b'\x22'),
Pattern::Single(b'\x33'),
+2 -3
View File
@@ -38,11 +38,10 @@ pub fn parse_obsolete(src: &OsString) -> Option<Result<ObsoleteArgs, ParseError>
let sign = if let Some(r) = rest.strip_prefix('-') {
rest = r;
'-'
} else if let Some(r) = rest.strip_prefix('+') {
} else {
let r = rest.strip_prefix('+')?;
rest = r;
'+'
} else {
return None;
};
let end_num = rest
@@ -413,7 +413,7 @@ fn bd_to_string_exp_with_prec(bd: &BigDecimal, precision: usize) -> (String, i64
// In the unlikely case we had an overflow, correct for that.
if digits.len() == precision + 1 {
debug_assert!(&digits[precision..] == "0");
debug_assert_eq!(&digits[precision..], "0");
digits.truncate(precision);
p -= 1;
}
+2 -2
View File
@@ -235,8 +235,8 @@ fn is_root(path: &Path, would_traverse_symlink: bool) -> bool {
// which we need to avoid here.
// All directory-ish paths match "*/", except ".", "..", "*/.", and "*/..".
let path_bytes = path.as_os_str().as_encoded_bytes();
let looks_like_dir = path_bytes == [b'.']
|| path_bytes == [b'.', b'.']
let looks_like_dir = path_bytes == *b"."
|| path_bytes == *b".."
|| path_bytes.ends_with(&[MAIN_SEPARATOR as u8])
|| path_bytes.ends_with(&[MAIN_SEPARATOR as u8, b'.'])
|| path_bytes.ends_with(&[MAIN_SEPARATOR as u8, b'.', b'.']);