Clippy and cleanups

This commit is contained in:
Paul Masurel
2025-08-01 11:38:16 +09:00
parent c301e7b1c4
commit dc0aa3d734
17 changed files with 28 additions and 29 deletions

View File

@@ -1,3 +1,7 @@
// manual divceil actually generates code that is not optimal (to accept the full range of u32) and
// perf matters here.
#![allow(clippy::manual_div_ceil)]
use std::io;
use std::ops::{Range, RangeInclusive};

View File

@@ -140,10 +140,9 @@ impl BlockedBitpacker {
pub fn iter(&self) -> impl Iterator<Item = u64> + '_ {
// todo performance: we could decompress a whole block and cache it instead
let bitpacked_elems = self.offset_and_bits.len() * BLOCK_SIZE;
let iter = (0..bitpacked_elems)
(0..bitpacked_elems)
.map(move |idx| self.get(idx))
.chain(self.buffer.iter().cloned());
iter
.chain(self.buffer.iter().cloned())
}
}

View File

@@ -1,3 +1,5 @@
// #[allow(clippy::manual_div_ceil)]
mod bitpacker;
mod blocked_bitpacker;
mod filter_vec;

View File

@@ -1,3 +1,5 @@
#![allow(clippy::manual_div_ceil)]
mod column_type;
mod format_version;
mod merge;

View File

@@ -17,7 +17,7 @@
//! column.
//! - [column_values]: Stores the values of a column in a dense format.
#![cfg_attr(all(feature = "unstable", test), feature(test))]
// #![cfg_attr(all(feature = "unstable", test), feature(test))]
#[cfg(test)]
#[macro_use]

View File

@@ -9,7 +9,7 @@ use crate::ByteCount;
pub struct TinySet(u64);
impl fmt::Debug for TinySet {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.into_iter().collect::<Vec<u32>>().fmt(f)
}
}
@@ -182,6 +182,7 @@ pub struct BitSet {
max_value: u32,
}
#[inline(always)]
fn num_buckets(max_val: u32) -> u32 {
(max_val + 63u32) / 64u32
}

View File

@@ -1,4 +1,6 @@
#![allow(clippy::len_without_is_empty)]
// manual divceil actually generates code that is not optimal (to accept the full range of u32) and
// perf matters here.
#![allow(clippy::len_without_is_empty, clippy::manual_div_ceil)]
use std::ops::Deref;

View File

@@ -305,15 +305,14 @@ fn term_group_infallible(inp: &str) -> JResult<&str, UserInputAst> {
let (inp, (field_name, _, _, _)) =
tuple((field_name, multispace0, char('('), multispace0))(inp).expect("precondition failed");
let res = delimited_infallible(
delimited_infallible(
nothing,
map(ast_infallible, |(mut ast, errors)| {
ast.set_default_field(field_name.to_string());
(ast, errors)
}),
opt_i_err(char(')'), "expected ')'"),
)(inp);
res
)(inp)
}
fn exists(inp: &str) -> IResult<&str, UserInputLeaf> {

View File

@@ -484,7 +484,6 @@ impl FacetCounts {
#[cfg(test)]
mod tests {
use std::collections::BTreeSet;
use std::iter;
use columnar::Dictionary;
use rand::distributions::Uniform;

View File

@@ -40,9 +40,6 @@ const COMPRESSION_BLOCK_SIZE: usize = BitPacker4x::BLOCK_LEN;
#[cfg(test)]
pub(crate) mod tests {
use std::iter;
use proptest::prelude::*;
use proptest::sample::select;

View File

@@ -302,7 +302,6 @@ fn is_sorted<I: Iterator<Item = DocId>>(mut it: I) -> bool {
mod tests {
use std::cmp::Ordering;
use std::collections::BinaryHeap;
use std::iter;
use proptest::prelude::*;

View File

@@ -1561,8 +1561,6 @@ fn to_ascii(text: &str, output: &mut String) {
#[cfg(test)]
mod tests {
use std::iter;
use super::to_ascii;
use crate::tokenizer::{AsciiFoldingFilter, RawTokenizer, SimpleTokenizer, TextAnalyzer};

View File

@@ -308,10 +308,9 @@ impl<TSSTable: SSTable> Dictionary<TSSTable> {
}
}
_ => {
return Err(io::Error::new(
io::ErrorKind::Other,
format!("Unsupported sstable version, expected one of [2, 3], found {version}"),
));
return Err(io::Error::other(format!(
"Unsupported sstable version, expected one of [2, 3], found {version}"
)));
}
};
@@ -697,10 +696,9 @@ mod tests {
fn read_bytes(&self, range: Range<usize>) -> std::io::Result<OwnedBytes> {
let allowed_range = self.allowed_range.lock().unwrap();
if !allowed_range.contains(&range.start) || !allowed_range.contains(&(range.end - 1)) {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
format!("invalid range, allowed {allowed_range:?}, requested {range:?}"),
));
return Err(std::io::Error::other(format!(
"invalid range, allowed {allowed_range:?}, requested {range:?}"
)));
}
Ok(self.bytes.slice(range))

View File

@@ -1,3 +1,5 @@
#![allow(clippy::manual_div_ceil)]
//! `tantivy_sstable` is a crate that provides a sorted string table data structure.
//!
//! It is used in `tantivy` to store the term dictionary.

View File

@@ -394,7 +394,7 @@ impl SSTableIndexBuilder {
fn fst_error_to_io_error(error: tantivy_fst::Error) -> io::Error {
match error {
tantivy_fst::Error::Fst(fst_error) => io::Error::new(io::ErrorKind::Other, fst_error),
tantivy_fst::Error::Fst(fst_error) => io::Error::other(fst_error),
tantivy_fst::Error::Io(ioerror) => ioerror,
}
}

View File

@@ -10,8 +10,7 @@ pub fn fast_short_slice_copy(src: &[u8], dst: &mut [u8]) {
#[track_caller]
fn len_mismatch_fail(dst_len: usize, src_len: usize) -> ! {
panic!(
"source slice length ({}) does not match destination slice length ({})",
src_len, dst_len,
"source slice length ({src_len}) does not match destination slice length ({dst_len})",
);
}

View File

@@ -1,5 +1,3 @@
#![cfg_attr(all(feature = "unstable", test), feature(test))]
#[cfg(all(test, feature = "unstable"))]
extern crate test;