Skip to content

Commit

Permalink
clippy (#5512)
Browse files Browse the repository at this point in the history
  • Loading branch information
PSeitz authored Oct 23, 2024
1 parent 21cec26 commit 02a5b6a
Show file tree
Hide file tree
Showing 27 changed files with 48 additions and 45 deletions.
1 change: 1 addition & 0 deletions quickwit/quickwit-actors/src/universe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use crate::spawn_builder::{SpawnBuilder, SpawnContext};
use crate::{Actor, ActorExitStatus, Command, Inbox, Mailbox, QueueCapacity};

/// Universe serves as the top-level context in which Actor can be spawned.
///
/// It is *not* a singleton. A typical application will usually have only one universe hosting all
/// of the actors but it is not a requirement.
///
Expand Down
2 changes: 1 addition & 1 deletion quickwit/quickwit-cli/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ struct Printer<'a> {
pub stdout: &'a mut Stdout,
}

impl<'a> Printer<'a> {
impl Printer<'_> {
pub fn print_header(&mut self, header: &str) -> io::Result<()> {
write!(&mut self.stdout, " {}", header.bright_blue())?;
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion quickwit/quickwit-cli/src/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ struct Printer<'a> {
pub stdout: &'a mut Stdout,
}

impl<'a> Printer<'a> {
impl Printer<'_> {
pub fn print_header(&mut self, header: &str) -> io::Result<()> {
write!(&mut self.stdout, " {}", header.bright_blue())?;
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions quickwit/quickwit-common/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ pub struct GaugeGuard<'a> {
delta: i64,
}

impl<'a> std::fmt::Debug for GaugeGuard<'a> {
impl std::fmt::Debug for GaugeGuard<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.delta.fmt(f)
}
Expand All @@ -262,7 +262,7 @@ impl<'a> GaugeGuard<'a> {
}
}

impl<'a> Drop for GaugeGuard<'a> {
impl Drop for GaugeGuard<'_> {
fn drop(&mut self) {
self.gauge.sub(self.delta)
}
Expand Down
8 changes: 4 additions & 4 deletions quickwit/quickwit-common/src/sorted_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ impl<T> SortedIterator for T where T: Iterator + Sorted {}

impl<K, V> Sorted for btree_map::IntoKeys<K, V> {}
impl<K, V> Sorted for btree_map::IntoValues<K, V> {}
impl<'a, K, V> Sorted for btree_map::Keys<'a, K, V> {}
impl<'a, K, V> Sorted for btree_map::Values<'a, K, V> {}
impl<K, V> Sorted for btree_map::Keys<'_, K, V> {}
impl<K, V> Sorted for btree_map::Values<'_, K, V> {}
impl<K> Sorted for btree_set::IntoIter<K> {}
impl<'a, K> Sorted for btree_set::Iter<'a, K> {}
impl<K> Sorted for btree_set::Iter<'_, K> {}

/// Same as [`SortedIterator`] but for (key, value) pairs sorted by key.
pub trait SortedByKeyIterator<K, V>: Iterator + Sized {
Expand Down Expand Up @@ -194,7 +194,7 @@ where
impl<T, K, V> SortedByKeyIterator<K, V> for T where T: Iterator<Item = (K, V)> + Sorted {}

impl<K, V> Sorted for btree_map::IntoIter<K, V> {}
impl<'a, K, V> Sorted for btree_map::Iter<'a, K, V> {}
impl<K, V> Sorted for btree_map::Iter<'_, K, V> {}

#[cfg(test)]
mod tests {
Expand Down
2 changes: 1 addition & 1 deletion quickwit/quickwit-common/src/temp_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub struct Builder<'a> {
num_rand_chars: usize,
}

impl<'a> Default for Builder<'a> {
impl Default for Builder<'_> {
fn default() -> Self {
Self {
parts: Default::default(),
Expand Down
4 changes: 2 additions & 2 deletions quickwit/quickwit-control-plane/src/indexing_scheduler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ struct IndexingPlansDiff<'a> {
pub unplanned_tasks_by_node_id: FnvHashMap<&'a str, Vec<&'a IndexingTask>>,
}

impl<'a> IndexingPlansDiff<'a> {
impl IndexingPlansDiff<'_> {
pub fn has_same_nodes(&self) -> bool {
self.missing_node_ids.is_empty() && self.unplanned_node_ids.is_empty()
}
Expand Down Expand Up @@ -454,7 +454,7 @@ fn get_shard_locality_metrics(
}
}

impl<'a> fmt::Debug for IndexingPlansDiff<'a> {
impl fmt::Debug for IndexingPlansDiff<'_> {
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
if self.has_same_nodes() && self.has_same_tasks() {
return write!(formatter, "EmptyIndexingPlansDiff");
Expand Down
1 change: 1 addition & 0 deletions quickwit/quickwit-directories/src/bundle_directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ impl Debug for BundleDirectory {
}

/// Loads the split footer from a storage and path.
///
/// Returns (SplitFooter, BundleFooter)
/// SplitFooter [BundleMetadata, BundleMetadata Len, Hotcache, Hotcache len]
/// BundleFooter [BundleMetadata, BundleMetadata Len]
Expand Down
2 changes: 1 addition & 1 deletion quickwit/quickwit-doc-mapper/src/query_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl<'a> ExtractTermSetFields<'a> {
}
}

impl<'a, 'b> QueryAstVisitor<'a> for ExtractTermSetFields<'b> {
impl<'a> QueryAstVisitor<'a> for ExtractTermSetFields<'_> {
type Err = anyhow::Error;

fn visit_term_set(&mut self, term_set_query: &'a TermSetQuery) -> anyhow::Result<()> {
Expand Down
1 change: 1 addition & 0 deletions quickwit/quickwit-indexing/src/actors/uploader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub enum UploaderType {
}

/// [`SplitsUpdateMailbox`] wraps either a [`Mailbox<Sequencer>`] or [`Mailbox<Publisher>`].
///
/// It makes it possible to send a [`SplitsUpdate`] either to the [`Sequencer`] or directly
/// to [`Publisher`]. It is used in combination with `SplitsUpdateSender` that will do the send.
///
Expand Down
2 changes: 1 addition & 1 deletion quickwit/quickwit-indexing/src/merge_policy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ pub fn nop_merge_policy() -> Arc<dyn MergePolicy> {

struct SplitShortDebug<'a>(&'a SplitMetadata);

impl<'a> fmt::Debug for SplitShortDebug<'a> {
impl fmt::Debug for SplitShortDebug<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Split")
.field("split_id", &self.0.split_id())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ impl StableLogMergePolicy {
head + (self.config.merge_factor - 2)
};
if tail.is_empty() || num_docs <= first_level_min_saturation_docs as u64 {
return (num_docs as usize + head - 1) / head;
return (num_docs as usize).div_ceil(head);
}
num_docs -= first_level_min_saturation_docs as u64;
self.config.merge_factor - 1 + self.max_num_splits_knowning_levels(num_docs, tail, sorted)
Expand Down
8 changes: 3 additions & 5 deletions quickwit/quickwit-metastore/src/metastore/file_backed/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1915,7 +1915,7 @@ mod tests {
}
indexes_json_valid_put -= 1;
}
return block_on(ram_storage_clone.put(path, put_payload));
block_on(ram_storage_clone.put(path, put_payload))
});
let metastore = FileBackedMetastore::for_test(Arc::new(mock_storage));
let index_config = IndexConfig::for_test(index_id, "ram:///indexes/test-index");
Expand Down Expand Up @@ -1967,9 +1967,7 @@ mod tests {
mock_storage
.expect_put()
.times(1)
.returning(move |path, put_payload| {
return block_on(ram_storage_clone.put(path, put_payload));
});
.returning(move |path, put_payload| block_on(ram_storage_clone.put(path, put_payload)));
let metastore = FileBackedMetastore::for_test(Arc::new(mock_storage));

// Delete index
Expand Down Expand Up @@ -2024,7 +2022,7 @@ mod tests {
}
indexes_json_valid_put -= 1;
}
return block_on(ram_storage_clone.put(path, put_payload));
block_on(ram_storage_clone.put(path, put_payload))
});
let metastore = FileBackedMetastore::for_test(Arc::new(mock_storage));

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions quickwit/quickwit-proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl TryFrom<metastore::DeleteQuery> for search::SearchRequest {
/// `MutMetadataMap` used to extract [`tonic::metadata::MetadataMap`] from a request.
pub struct MutMetadataMap<'a>(&'a mut tonic::metadata::MetadataMap);

impl<'a> Injector for MutMetadataMap<'a> {
impl Injector for MutMetadataMap<'_> {
/// Sets a key-value pair in the [`MetadataMap`]. No-op if the key or value is invalid.
fn set(&mut self, key: &str, value: String) {
if let Ok(metadata_key) = tonic::metadata::MetadataKey::from_bytes(key.as_bytes()) {
Expand All @@ -155,7 +155,7 @@ impl<'a> Injector for MutMetadataMap<'a> {
}
}

impl<'a> Extractor for MutMetadataMap<'a> {
impl Extractor for MutMetadataMap<'_> {
/// Gets a value for a key from the MetadataMap. If the value can't be converted to &str,
/// returns None.
fn get(&self, key: &str) -> Option<&str> {
Expand Down Expand Up @@ -195,7 +195,7 @@ impl Interceptor for SpanContextInterceptor {
/// tracing keys from request's headers.
struct MetadataMap<'a>(&'a tonic::metadata::MetadataMap);

impl<'a> Extractor for MetadataMap<'a> {
impl Extractor for MetadataMap<'_> {
/// Gets a value for a key from the MetadataMap. If the value can't be converted to &str,
/// returns None.
fn get(&self, key: &str) -> Option<&str> {
Expand Down
8 changes: 4 additions & 4 deletions quickwit/quickwit-query/src/json_literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl<'a> InterpretUserInput<'a> for f64 {
}
}

impl<'a> InterpretUserInput<'a> for bool {
impl InterpretUserInput<'_> for bool {
fn interpret_bool(b: bool) -> Option<Self> {
Some(b)
}
Expand All @@ -139,14 +139,14 @@ impl<'a> InterpretUserInput<'a> for bool {
}
}

impl<'a> InterpretUserInput<'a> for Ipv6Addr {
impl InterpretUserInput<'_> for Ipv6Addr {
fn interpret_str(text: &str) -> Option<Self> {
let ip_addr: IpAddr = text.parse().ok()?;
Some(ip_addr.into_ipv6_addr())
}
}

impl<'a> InterpretUserInput<'a> for tantivy::DateTime {
impl InterpretUserInput<'_> for tantivy::DateTime {
fn interpret_str(text: &str) -> Option<Self> {
let date_time_formats = get_default_date_time_format();
if let Ok(datetime) = parse_date_time_str(text, date_time_formats) {
Expand All @@ -171,7 +171,7 @@ const LENIENT_BASE64_ENGINE: base64::engine::GeneralPurpose = base64::engine::Ge
.with_decode_padding_mode(base64::engine::DecodePaddingMode::Indifferent),
);

impl<'a> InterpretUserInput<'a> for Vec<u8> {
impl InterpretUserInput<'_> for Vec<u8> {
fn interpret_str(mut text: &str) -> Option<Vec<u8>> {
let Some(first_byte) = text.as_bytes().first().copied() else {
return Some(Vec::new());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn char_grouping(c: char) -> Grouping {
}
}

impl<'a> TokenStream for ChineseTokenStream<'a> {
impl TokenStream for ChineseTokenStream<'_> {
fn advance(&mut self) -> bool {
self.token.text.clear();
self.token.position = self.token.position.wrapping_add(1);
Expand Down
6 changes: 3 additions & 3 deletions quickwit/quickwit-query/src/tokenizers/code_tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ enum AdvanceResult {
Backtrack,
}

impl<'a> CodeTokenStream<'a> {
impl CodeTokenStream<'_> {
fn advance_inner(&mut self, enable_hex: bool) -> bool {
// this is cheap, just a copy of a few ptrs and integers
let checkpoint = self.chars.clone();
Expand Down Expand Up @@ -116,7 +116,7 @@ impl<'a> CodeTokenStream<'a> {
}
}

impl<'a> TokenStream for CodeTokenStream<'a> {
impl TokenStream for CodeTokenStream<'_> {
fn advance(&mut self) -> bool {
self.token.text.clear();
self.token.position = self.token.position.wrapping_add(1);
Expand All @@ -133,7 +133,7 @@ impl<'a> TokenStream for CodeTokenStream<'a> {
}
}

impl<'a> CodeTokenStream<'a> {
impl CodeTokenStream<'_> {
fn update_token(&mut self, token_offsets: Range<usize>) {
self.token.offset_from = token_offsets.start;
self.token.offset_to = token_offsets.end;
Expand Down
4 changes: 2 additions & 2 deletions quickwit/quickwit-query/src/tokenizers/multilang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub enum MultiLanguageTokenStream<'a> {
Simple(SimpleTokenStream<'a>),
}

impl<'a> TokenStream for MultiLanguageTokenStream<'a> {
impl TokenStream for MultiLanguageTokenStream<'_> {
fn advance(&mut self) -> bool {
match self {
MultiLanguageTokenStream::Empty => false,
Expand Down Expand Up @@ -188,7 +188,7 @@ pub struct LinderaTokenStream<'a> {
pub token: &'a mut Token,
}

impl<'a> TokenStream for LinderaTokenStream<'a> {
impl TokenStream for LinderaTokenStream<'_> {
fn advance(&mut self) -> bool {
if self.tokens.is_empty() {
return false;
Expand Down
4 changes: 2 additions & 2 deletions quickwit/quickwit-search/src/leaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ struct RemoveTimestampRange<'a> {
end_timestamp: Bound<DateTime>,
}

impl<'a> RemoveTimestampRange<'a> {
impl RemoveTimestampRange<'_> {
fn update_start_timestamp(
&mut self,
lower_bound: &quickwit_query::JsonLiteral,
Expand Down Expand Up @@ -755,7 +755,7 @@ impl<'a> RemoveTimestampRange<'a> {
}
}

impl<'a> QueryAstTransformer for RemoveTimestampRange<'a> {
impl QueryAstTransformer for RemoveTimestampRange<'_> {
type Err = std::convert::Infallible;

fn transform_bool(&mut self, mut bool_query: BoolQuery) -> Result<Option<QueryAst>, Self::Err> {
Expand Down
2 changes: 1 addition & 1 deletion quickwit/quickwit-search/src/retry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl<Request, Response, Error> RetryPolicy<Request, Response, Error> for Default
}
}

impl<'a> Job for &'a str {
impl Job for &str {
fn split_id(&self) -> &str {
self
}
Expand Down
4 changes: 2 additions & 2 deletions quickwit/quickwit-search/src/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,7 @@ struct ExtractTimestampRange<'a> {
end_timestamp: Option<i64>,
}

impl<'a> ExtractTimestampRange<'a> {
impl ExtractTimestampRange<'_> {
fn update_start_timestamp(
&mut self,
lower_bound: &quickwit_query::JsonLiteral,
Expand Down Expand Up @@ -1489,7 +1489,7 @@ impl<'a> ExtractTimestampRange<'a> {
}
}

impl<'a, 'b> QueryAstVisitor<'b> for ExtractTimestampRange<'a> {
impl<'b> QueryAstVisitor<'b> for ExtractTimestampRange<'_> {
type Err = std::convert::Infallible;

fn visit_bool(&mut self, bool_query: &'b BoolQuery) -> Result<(), Self::Err> {
Expand Down
4 changes: 2 additions & 2 deletions quickwit/quickwit-search/src/search_stream/leaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,10 @@ impl std::fmt::Display for SearchStreamRequestFields {
}
}

impl<'a> SearchStreamRequestFields {
impl SearchStreamRequestFields {
pub fn from_request(
stream_request: &SearchStreamRequest,
schema: &'a Schema,
schema: &Schema,
doc_mapper: &DocMapper,
) -> crate::Result<SearchStreamRequestFields> {
let fast_field = schema.get_field(&stream_request.fast_field)?;
Expand Down
3 changes: 1 addition & 2 deletions quickwit/quickwit-search/src/top_k_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,7 @@ where
}
}

impl<'a, V1, V2, const REVERSE_DOCID: bool> Iterator
for SpecSortingFieldIter<'a, V1, V2, REVERSE_DOCID>
impl<V1, V2, const REVERSE_DOCID: bool> Iterator for SpecSortingFieldIter<'_, V1, V2, REVERSE_DOCID>
where
V1: Copy + PartialEq + Eq + PartialOrd + Ord + IntoOptionU64 + Debug,
V2: Copy + PartialEq + Eq + PartialOrd + Ord + IntoOptionU64 + Debug,
Expand Down
1 change: 1 addition & 0 deletions quickwit/quickwit-serve/src/rest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ fn api_v1_routes(
}

/// This function returns a formatted error based on the given rejection reason.
///
/// The ordering of rejection processing is very important, we need to start
/// with the most specific rejections and end with the most generic. If not, Quickwit
/// will return useless errors to the user.
Expand Down
Loading

0 comments on commit 02a5b6a

Please sign in to comment.