From 4708171a32dbdea41c5a015c9287d2e40e93f3cc Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Tue, 16 Apr 2024 04:27:06 +0200 Subject: [PATCH] Fix some of the things current Clippy complains about (#2363) --- common/src/bitset.rs | 2 +- src/aggregation/bucket/mod.rs | 11 ++++++----- src/aggregation/mod.rs | 4 ---- src/collector/facet_collector.rs | 2 +- src/lib.rs | 9 +++++---- sstable/src/lib.rs | 1 - 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/common/src/bitset.rs b/common/src/bitset.rs index c248aacb7c..b25a52845c 100644 --- a/common/src/bitset.rs +++ b/common/src/bitset.rs @@ -1,5 +1,5 @@ use std::io::Write; -use std::{fmt, io, u64}; +use std::{fmt, io}; use ownedbytes::OwnedBytes; diff --git a/src/aggregation/bucket/mod.rs b/src/aggregation/bucket/mod.rs index cd6d980cdd..f1eaa975b8 100644 --- a/src/aggregation/bucket/mod.rs +++ b/src/aggregation/bucket/mod.rs @@ -28,6 +28,7 @@ mod term_agg; mod term_missing_agg; use std::collections::HashMap; +use std::fmt; pub use histogram::*; pub use range::*; @@ -72,12 +73,12 @@ impl From<&str> for OrderTarget { } } -impl ToString for OrderTarget { - fn to_string(&self) -> String { +impl fmt::Display for OrderTarget { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - OrderTarget::Key => "_key".to_string(), - OrderTarget::Count => "_count".to_string(), - OrderTarget::SubAggregation(agg) => agg.to_string(), + OrderTarget::Key => f.write_str("_key"), + OrderTarget::Count => f.write_str("_count"), + OrderTarget::SubAggregation(agg) => agg.fmt(f), } } } diff --git a/src/aggregation/mod.rs b/src/aggregation/mod.rs index c88d14c6e4..fbb2925dd1 100644 --- a/src/aggregation/mod.rs +++ b/src/aggregation/mod.rs @@ -159,10 +159,6 @@ use itertools::Itertools; use serde::de::{self, Visitor}; use serde::{Deserialize, Deserializer, Serialize}; -pub(crate) fn invalid_agg_request(message: String) -> crate::TantivyError { - crate::TantivyError::AggregationError(AggregationError::InvalidRequest(message)) -} - fn parse_str_into_f64(value: &str) -> Result { let parsed = value.parse::().map_err(|_err| { de::Error::custom(format!("Failed to parse f64 from string: {:?}", value)) diff --git a/src/collector/facet_collector.rs b/src/collector/facet_collector.rs index f09252f264..16759f3b26 100644 --- a/src/collector/facet_collector.rs +++ b/src/collector/facet_collector.rs @@ -1,7 +1,7 @@ use std::cmp::Ordering; use std::collections::{btree_map, BTreeMap, BTreeSet, BinaryHeap}; +use std::io; use std::ops::Bound; -use std::{io, u64, usize}; use crate::collector::{Collector, SegmentCollector}; use crate::fastfield::FacetReader; diff --git a/src/lib.rs b/src/lib.rs index d087c96faf..077725f570 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -255,7 +255,7 @@ pub struct Version { impl fmt::Debug for Version { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self.to_string()) + fmt::Display::fmt(self, f) } } @@ -266,9 +266,10 @@ static VERSION: Lazy = Lazy::new(|| Version { index_format_version: INDEX_FORMAT_VERSION, }); -impl ToString for Version { - fn to_string(&self) -> String { - format!( +impl fmt::Display for Version { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!( + f, "tantivy v{}.{}.{}, index_format v{}", self.major, self.minor, self.patch, self.index_format_version ) diff --git a/sstable/src/lib.rs b/sstable/src/lib.rs index dadf43489a..87b8f29d9d 100644 --- a/sstable/src/lib.rs +++ b/sstable/src/lib.rs @@ -1,6 +1,5 @@ use std::io::{self, Write}; use std::ops::Range; -use std::usize; use merge::ValueMerger;