From 2e3d052c54e6e4b32954141f0be27a05e0614c98 Mon Sep 17 00:00:00 2001
From: sigaloid <69441971+sigaloid@users.noreply.github.com>
Date: Fri, 20 Aug 2021 15:57:35 -0400
Subject: [PATCH 1/4] cargo +nightly clippy --fix -Z unstable-options
---
src/core/index.rs | 2 +-
src/functional_test.rs | 2 +-
src/indexer/merger.rs | 5 ++---
src/indexer/merger_sorted_index_test.rs | 9 +++------
src/postings/block_segment_postings.rs | 2 +-
src/schema/mod.rs | 2 +-
6 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/src/core/index.rs b/src/core/index.rs
index b5b04dcf2a..4ad143219a 100644
--- a/src/core/index.rs
+++ b/src/core/index.rs
@@ -535,7 +535,7 @@ impl Index {
let mut damaged_files = HashSet::new();
for path in active_existing_files {
- if !self.directory.validate_checksum(&path)? {
+ if !self.directory.validate_checksum(path)? {
damaged_files.insert((*path).clone());
}
}
diff --git a/src/functional_test.rs b/src/functional_test.rs
index f76e42e7bc..a719033413 100644
--- a/src/functional_test.rs
+++ b/src/functional_test.rs
@@ -141,7 +141,7 @@ const LOREM: &str = "Doc Lorem ipsum dolor sit amet, consectetur adipiscing elit
fn get_text() -> String {
use rand::seq::SliceRandom;
let mut rng = thread_rng();
- let tokens: Vec<_> = LOREM.split(" ").collect();
+ let tokens: Vec<_> = LOREM.split(' ').collect();
let random_val = rng.gen_range(0..20);
(0..random_val)
diff --git a/src/indexer/merger.rs b/src/indexer/merger.rs
index 8d07506ccb..537d36905f 100644
--- a/src/indexer/merger.rs
+++ b/src/indexer/merger.rs
@@ -149,8 +149,7 @@ impl TermOrdinalMapping {
self.per_segment_new_term_ordinals
.iter()
.flat_map(|term_ordinals| term_ordinals.iter().cloned().max())
- .max()
- .unwrap_or_else(TermOrdinal::default)
+ .max().unwrap_or_default()
}
}
@@ -966,7 +965,7 @@ impl IndexMerger {
doc_id_and_positions.sort_unstable_by_key(|&(doc_id, _, _)| doc_id);
for (doc_id, term_freq, positions) in &doc_id_and_positions {
- let delta_positions = delta_computer.compute_delta(&positions);
+ let delta_positions = delta_computer.compute_delta(positions);
field_serializer.write_doc(*doc_id, *term_freq, delta_positions);
}
doc_id_and_positions.clear();
diff --git a/src/indexer/merger_sorted_index_test.rs b/src/indexer/merger_sorted_index_test.rs
index 629823f5f0..579a5c6404 100644
--- a/src/indexer/merger_sorted_index_test.rs
+++ b/src/indexer/merger_sorted_index_test.rs
@@ -261,8 +261,7 @@ mod tests {
assert_eq!(
postings.doc_freq_given_deletes(
segment_reader
- .delete_bitset()
- .unwrap_or_else(|| &&fallback_bitset)
+ .delete_bitset().unwrap_or(&fallback_bitset)
),
2
);
@@ -342,8 +341,7 @@ mod tests {
assert_eq!(
postings.doc_freq_given_deletes(
segment_reader
- .delete_bitset()
- .unwrap_or_else(|| &&fallback_bitset)
+ .delete_bitset().unwrap_or(&fallback_bitset)
),
2
);
@@ -454,8 +452,7 @@ mod tests {
assert_eq!(
postings.doc_freq_given_deletes(
segment_reader
- .delete_bitset()
- .unwrap_or_else(|| &&fallback_bitset)
+ .delete_bitset().unwrap_or(&fallback_bitset)
),
2
);
diff --git a/src/postings/block_segment_postings.rs b/src/postings/block_segment_postings.rs
index d12e8e994d..941d3f6b7b 100644
--- a/src/postings/block_segment_postings.rs
+++ b/src/postings/block_segment_postings.rs
@@ -209,7 +209,7 @@ impl BlockSegmentPostings {
#[inline]
pub(crate) fn full_block(&self) -> &[DocId; COMPRESSION_BLOCK_SIZE] {
debug_assert!(self.block_is_loaded());
- &self.doc_decoder.full_output()
+ self.doc_decoder.full_output()
}
/// Return the document at index `idx` of the block.
diff --git a/src/schema/mod.rs b/src/schema/mod.rs
index bed26a295f..b1ea12e273 100644
--- a/src/schema/mod.rs
+++ b/src/schema/mod.rs
@@ -157,7 +157,7 @@ pub use self::int_options::IntOptions;
/// A field name can be any character, must have at least one character
/// and must not start with a `-`.
pub fn is_valid_field_name(field_name: &str) -> bool {
- field_name.len() > 0 && !field_name.starts_with('-')
+ !field_name.is_empty() && !field_name.starts_with('-')
}
#[cfg(test)]
From 7e0fe20adab622228b1e1a7f2cfde5ed2611f8ad Mon Sep 17 00:00:00 2001
From: sigaloid <69441971+sigaloid@users.noreply.github.com>
Date: Fri, 20 Aug 2021 15:57:50 -0400
Subject: [PATCH 2/4] cargo fmt (again)
---
src/indexer/merger.rs | 3 ++-
src/indexer/merger_sorted_index_test.rs | 9 +++------
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/src/indexer/merger.rs b/src/indexer/merger.rs
index 537d36905f..295a5fde66 100644
--- a/src/indexer/merger.rs
+++ b/src/indexer/merger.rs
@@ -149,7 +149,8 @@ impl TermOrdinalMapping {
self.per_segment_new_term_ordinals
.iter()
.flat_map(|term_ordinals| term_ordinals.iter().cloned().max())
- .max().unwrap_or_default()
+ .max()
+ .unwrap_or_default()
}
}
diff --git a/src/indexer/merger_sorted_index_test.rs b/src/indexer/merger_sorted_index_test.rs
index 579a5c6404..d06f0b40d4 100644
--- a/src/indexer/merger_sorted_index_test.rs
+++ b/src/indexer/merger_sorted_index_test.rs
@@ -260,8 +260,7 @@ mod tests {
let fallback_bitset = DeleteBitSet::for_test(&[0], 100);
assert_eq!(
postings.doc_freq_given_deletes(
- segment_reader
- .delete_bitset().unwrap_or(&fallback_bitset)
+ segment_reader.delete_bitset().unwrap_or(&fallback_bitset)
),
2
);
@@ -340,8 +339,7 @@ mod tests {
let fallback_bitset = DeleteBitSet::for_test(&[0], 100);
assert_eq!(
postings.doc_freq_given_deletes(
- segment_reader
- .delete_bitset().unwrap_or(&fallback_bitset)
+ segment_reader.delete_bitset().unwrap_or(&fallback_bitset)
),
2
);
@@ -451,8 +449,7 @@ mod tests {
let fallback_bitset = DeleteBitSet::for_test(&[0], 100);
assert_eq!(
postings.doc_freq_given_deletes(
- segment_reader
- .delete_bitset().unwrap_or(&fallback_bitset)
+ segment_reader.delete_bitset().unwrap_or(&fallback_bitset)
),
2
);
From 707970c49ed05f3b31dc915ec1fa263702fe092a Mon Sep 17 00:00:00 2001
From: sigaloid <69441971+sigaloid@users.noreply.github.com>
Date: Fri, 20 Aug 2021 16:05:55 -0400
Subject: [PATCH 3/4] clippy suggestions (ignoring f32->f64 comparison, not
sure what margin should be)
---
examples/custom_collector.rs | 10 ++++------
src/fastfield/serializer/mod.rs | 2 +-
src/postings/serializer.rs | 6 ++----
src/query/automaton_weight.rs | 5 +----
src/query/boolean_query/mod.rs | 2 +-
5 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/examples/custom_collector.rs b/examples/custom_collector.rs
index 9abf5fc44e..2b84d2cc20 100644
--- a/examples/custom_collector.rs
+++ b/examples/custom_collector.rs
@@ -86,12 +86,10 @@ impl Collector for StatsCollector {
fn merge_fruits(&self, segment_stats: Vec