From 10f056fbb471fc321bcd6f2631d71848d8b4393e Mon Sep 17 00:00:00 2001 From: Pascal Seitz Date: Thu, 1 Jul 2021 17:08:44 +0200 Subject: [PATCH] apply clippy fixes --- common/src/vint.rs | 6 +- fastfield_codecs/src/bitpacked.rs | 6 +- fastfield_codecs/src/linearinterpol.rs | 2 +- query-grammar/src/user_input_ast.rs | 2 +- rustfmt.sublime-workspace | 166 +++++++++++++++++++++++++ src/core/index.rs | 4 +- src/postings/block_segment_postings.rs | 8 +- src/query/regex_query.rs | 4 +- src/store/reader.rs | 4 +- src/termdict/tests.rs | 2 +- 10 files changed, 185 insertions(+), 19 deletions(-) create mode 100644 rustfmt.sublime-workspace diff --git a/common/src/vint.rs b/common/src/vint.rs index b64ba6bb6..994352644 100644 --- a/common/src/vint.rs +++ b/common/src/vint.rs @@ -106,7 +106,7 @@ pub fn read_u32_vint_no_advance(data: &[u8]) -> (u32, usize) { pub fn write_u32_vint(val: u32, writer: &mut W) -> io::Result<()> { let mut buf = [0u8; 8]; let data = serialize_vint_u32(val, &mut buf); - writer.write_all(&data) + writer.write_all(data) } impl VInt { @@ -181,8 +181,8 @@ mod tests { fn aux_test_vint(val: u64) { let mut v = [14u8; 10]; let num_bytes = VInt(val).serialize_into(&mut v); - for i in num_bytes..10 { - assert_eq!(v[i], 14u8); + for el in &v[num_bytes..10] { + assert_eq!(el, &14u8); } assert!(num_bytes > 0); if num_bytes < 10 { diff --git a/fastfield_codecs/src/bitpacked.rs b/fastfield_codecs/src/bitpacked.rs index a4d5b44a4..60e69ff28 100644 --- a/fastfield_codecs/src/bitpacked.rs +++ b/fastfield_codecs/src/bitpacked.rs @@ -35,7 +35,7 @@ impl<'data> FastFieldCodecReader for BitpackedFastFieldReader { } #[inline] fn get_u64(&self, doc: u64, data: &[u8]) -> u64 { - self.min_value_u64 + self.bit_unpacker.get(doc, &data) + self.min_value_u64 + self.bit_unpacker.get(doc, data) } #[inline] fn min_value(&self) -> u64 { @@ -147,7 +147,7 @@ mod tests { fn create_and_validate(data: &[u64], name: &str) { crate::tests::create_and_validate::( - &data, name, + data, name, ); } @@ -165,7 +165,7 @@ mod tests { fn bitpacked_fast_field_rand() { for _ in 0..500 { let mut data = (0..1 + rand::random::() as usize) - .map(|_| rand::random::() as u64 / 2 as u64) + .map(|_| rand::random::() as u64 / 2) .collect::>(); create_and_validate(&data, "rand"); diff --git a/fastfield_codecs/src/linearinterpol.rs b/fastfield_codecs/src/linearinterpol.rs index 3a80656a1..310ed45a7 100644 --- a/fastfield_codecs/src/linearinterpol.rs +++ b/fastfield_codecs/src/linearinterpol.rs @@ -78,7 +78,7 @@ impl FastFieldCodecReader for LinearInterpolFastFieldReader { #[inline] fn get_u64(&self, doc: u64, data: &[u8]) -> u64 { let calculated_value = get_calculated_value(self.footer.first_val, doc, self.slope); - (calculated_value + self.bit_unpacker.get(doc, &data)) - self.footer.offset + (calculated_value + self.bit_unpacker.get(doc, data)) - self.footer.offset } #[inline] diff --git a/query-grammar/src/user_input_ast.rs b/query-grammar/src/user_input_ast.rs index b954ebda0..005f3ea86 100644 --- a/query-grammar/src/user_input_ast.rs +++ b/query-grammar/src/user_input_ast.rs @@ -79,7 +79,7 @@ impl UserInputBound { match *self { UserInputBound::Inclusive(ref contents) => contents, UserInputBound::Exclusive(ref contents) => contents, - UserInputBound::Unbounded => &"*", + UserInputBound::Unbounded => "*", } } } diff --git a/rustfmt.sublime-workspace b/rustfmt.sublime-workspace new file mode 100644 index 000000000..096cc8a8e --- /dev/null +++ b/rustfmt.sublime-workspace @@ -0,0 +1,166 @@ +{ + "auto_complete": + { + "selected_items": + [ + ] + }, + "buffers": + [ + ], + "build_system": "", + "build_system_choices": + [ + ], + "build_varint": "", + "command_palette": + { + "height": 0.0, + "last_filter": "", + "selected_items": + [ + ], + "width": 0.0 + }, + "console": + { + "height": 0.0, + "history": + [ + ] + }, + "distraction_free": + { + "menu_visible": true, + "show_minimap": false, + "show_open_files": false, + "show_tabs": false, + "side_bar_visible": false, + "status_bar_visible": false + }, + "file_history": + [ + ], + "find": + { + "height": 24.0 + }, + "find_in_files": + { + "height": 0.0, + "where_history": + [ + ] + }, + "find_state": + { + "case_sensitive": false, + "find_history": + [ + ], + "highlight": true, + "in_selection": false, + "preserve_case": false, + "regex": false, + "replace_history": + [ + ], + "reverse": false, + "scrollbar_highlights": true, + "show_context": true, + "use_buffer2": true, + "use_gitignore": true, + "whole_word": false, + "wrap": true + }, + "groups": + [ + { + "sheets": + [ + ] + } + ], + "incremental_find": + { + "height": 24.0 + }, + "input": + { + "height": 0.0 + }, + "layout": + { + "cells": + [ + [ + 0, + 0, + 1, + 1 + ] + ], + "cols": + [ + 0.0, + 1.0 + ], + "rows": + [ + 0.0, + 1.0 + ] + }, + "menu_visible": true, + "output.find_results": + { + "height": 0.0 + }, + "pinned_build_system": "", + "project": "rustfmt.sublime-project", + "replace": + { + "height": 44.0 + }, + "save_all_on_build": true, + "select_file": + { + "height": 0.0, + "last_filter": "", + "selected_items": + [ + ], + "width": 0.0 + }, + "select_project": + { + "height": 0.0, + "last_filter": "", + "selected_items": + [ + ], + "width": 0.0 + }, + "select_symbol": + { + "height": 0.0, + "last_filter": "", + "selected_items": + [ + ], + "width": 0.0 + }, + "selected_group": 0, + "settings": + { + }, + "show_minimap": true, + "show_open_files": true, + "show_tabs": true, + "side_bar_visible": true, + "side_bar_width": 450.0, + "status_bar_visible": true, + "template_settings": + { + } +} diff --git a/src/core/index.rs b/src/core/index.rs index 3621e4d78..73a76c697 100644 --- a/src/core/index.rs +++ b/src/core/index.rs @@ -42,7 +42,7 @@ fn load_metas( "Meta file does not contain valid utf8 file.".to_string(), ) })?; - IndexMeta::deserialize(&meta_string, &inventory) + IndexMeta::deserialize(&meta_string, inventory) .map_err(|e| { DataCorruption::new( META_FILEPATH.to_path_buf(), @@ -604,7 +604,7 @@ mod tests { .is_ok()); assert!(Index::exists(&directory).unwrap()); assert!(Index::create( - directory.clone(), + directory, Schema::builder().build(), IndexSettings::default() ) diff --git a/src/postings/block_segment_postings.rs b/src/postings/block_segment_postings.rs index b82b866ff..c6e6f1f6b 100644 --- a/src/postings/block_segment_postings.rs +++ b/src/postings/block_segment_postings.rs @@ -482,11 +482,11 @@ mod tests { docs.push((i * i / 100) + i); } let mut block_postings = build_block_postings(&docs[..]); - for i in vec![0, 424, 10000] { - block_postings.seek(i); + for i in &[0, 424, 10000] { + block_postings.seek(*i); let docs = block_postings.docs(); - assert!(docs[0] <= i); - assert!(docs.last().cloned().unwrap_or(0u32) >= i); + assert!(docs[0] <= *i); + assert!(docs.last().cloned().unwrap_or(0u32) >= *i); } block_postings.seek(100_000); assert_eq!(block_postings.doc(COMPRESSION_BLOCK_SIZE - 1), TERMINATED); diff --git a/src/query/regex_query.rs b/src/query/regex_query.rs index 5db7a6f4c..e1f7239b3 100644 --- a/src/query/regex_query.rs +++ b/src/query/regex_query.rs @@ -58,7 +58,7 @@ pub struct RegexQuery { impl RegexQuery { /// Creates a new RegexQuery from a given pattern pub fn from_pattern(regex_pattern: &str, field: Field) -> crate::Result { - let regex = Regex::new(®ex_pattern) + let regex = Regex::new(regex_pattern) .map_err(|_| TantivyError::InvalidArgument(regex_pattern.to_string()))?; Ok(RegexQuery::from_regex(regex, field)) } @@ -169,7 +169,7 @@ mod test { verify_regex_query(matching_one, matching_zero, reader.clone()); - let matching_one = RegexQuery::from_regex(r1.clone(), field); + let matching_one = RegexQuery::from_regex(r1, field); let matching_zero = RegexQuery::from_regex(r2.clone(), field); verify_regex_query(matching_one, matching_zero, reader.clone()); diff --git a/src/store/reader.rs b/src/store/reader.rs index 3166986c0..64cef7339 100644 --- a/src/store/reader.rs +++ b/src/store/reader.rs @@ -163,7 +163,7 @@ impl StoreReader { let mut curr_checkpoint = checkpoint_block_iter.next(); let mut curr_block = curr_checkpoint .as_ref() - .map(|checkpoint| self.read_block(&checkpoint).map_err(|e| e.kind())); // map error in order to enable cloning + .map(|checkpoint| self.read_block(checkpoint).map_err(|e| e.kind())); // map error in order to enable cloning let mut block_start_pos = 0; let mut num_skipped = 0; let mut reset_block_pos = false; @@ -177,7 +177,7 @@ impl StoreReader { curr_checkpoint = checkpoint_block_iter.next(); curr_block = curr_checkpoint .as_ref() - .map(|checkpoint| self.read_block(&checkpoint).map_err(|e| e.kind())); + .map(|checkpoint| self.read_block(checkpoint).map_err(|e| e.kind())); reset_block_pos = true; num_skipped = 0; } diff --git a/src/termdict/tests.rs b/src/termdict/tests.rs index 99aa90944..b2d290589 100644 --- a/src/termdict/tests.rs +++ b/src/termdict/tests.rs @@ -25,7 +25,7 @@ fn test_empty_term_dictionary() { #[test] fn test_term_ordinals() -> crate::Result<()> { - const COUNTRIES: [&'static str; 7] = [ + const COUNTRIES: [&str; 7] = [ "San Marino", "Serbia", "Slovakia",