diff --git a/benchmarks/benches/indexing.rs b/benchmarks/benches/indexing.rs index 65f581b93..0c19b89cf 100644 --- a/benchmarks/benches/indexing.rs +++ b/benchmarks/benches/indexing.rs @@ -36,7 +36,7 @@ fn setup_index() -> Index { } fn setup_settings<'t>( - wtxn: &mut RwTxn<'t, '_>, + wtxn: &mut RwTxn<'t>, index: &'t Index, primary_key: &str, searchable_fields: &[&str], diff --git a/dump/src/reader/mod.rs b/dump/src/reader/mod.rs index 603c557d6..5bbf4ec4d 100644 --- a/dump/src/reader/mod.rs +++ b/dump/src/reader/mod.rs @@ -13,12 +13,12 @@ use crate::{Result, Version}; mod compat; -pub(self) mod v1; -pub(self) mod v2; -pub(self) mod v3; -pub(self) mod v4; -pub(self) mod v5; -pub(self) mod v6; +mod v1; +mod v2; +mod v3; +mod v4; +mod v5; +mod v6; pub type Document = serde_json::Map; pub type UpdateFile = dyn Iterator>; diff --git a/dump/src/reader/v1/settings.rs b/dump/src/reader/v1/settings.rs index 2f7976534..94343d150 100644 --- a/dump/src/reader/v1/settings.rs +++ b/dump/src/reader/v1/settings.rs @@ -56,8 +56,7 @@ pub enum RankingRule { Desc(String), } -static ASC_DESC_REGEX: Lazy = - Lazy::new(|| Regex::new(r#"(asc|desc)\(([\w_-]+)\)"#).unwrap()); +static ASC_DESC_REGEX: Lazy = Lazy::new(|| Regex::new(r"(asc|desc)\(([\w_-]+)\)").unwrap()); impl FromStr for RankingRule { type Err = (); diff --git a/filter-parser/src/lib.rs b/filter-parser/src/lib.rs index 5760c8865..fa5b70606 100644 --- a/filter-parser/src/lib.rs +++ b/filter-parser/src/lib.rs @@ -564,10 +564,10 @@ pub mod tests { #[test] fn parse_escaped() { - insta::assert_display_snapshot!(p(r#"title = 'foo\\'"#), @r#"{title} = {foo\}"#); - insta::assert_display_snapshot!(p(r#"title = 'foo\\\\'"#), @r#"{title} = {foo\\}"#); - insta::assert_display_snapshot!(p(r#"title = 'foo\\\\\\'"#), @r#"{title} = {foo\\\}"#); - insta::assert_display_snapshot!(p(r#"title = 'foo\\\\\\\\'"#), @r#"{title} = {foo\\\\}"#); + insta::assert_display_snapshot!(p(r"title = 'foo\\'"), @r#"{title} = {foo\}"#); + insta::assert_display_snapshot!(p(r"title = 'foo\\\\'"), @r#"{title} = {foo\\}"#); + insta::assert_display_snapshot!(p(r"title = 'foo\\\\\\'"), @r#"{title} = {foo\\\}"#); + insta::assert_display_snapshot!(p(r"title = 'foo\\\\\\\\'"), @r#"{title} = {foo\\\\}"#); // but it also works with other sequencies insta::assert_display_snapshot!(p(r#"title = 'foo\x20\n\t\"\'"'"#), @"{title} = {foo \n\t\"\'\"}"); } diff --git a/filter-parser/src/value.rs b/filter-parser/src/value.rs index 63d5ac384..1d70cb025 100644 --- a/filter-parser/src/value.rs +++ b/filter-parser/src/value.rs @@ -270,8 +270,8 @@ pub mod test { ("aaaa", "", rtok("", "aaaa"), "aaaa"), (r#"aa"aa"#, r#""aa"#, rtok("", "aa"), "aa"), (r#"aa\"aa"#, r#""#, rtok("", r#"aa\"aa"#), r#"aa"aa"#), - (r#"aa\\\aa"#, r#""#, rtok("", r#"aa\\\aa"#), r#"aa\\\aa"#), - (r#"aa\\"\aa"#, r#""\aa"#, rtok("", r#"aa\\"#), r#"aa\\"#), + (r"aa\\\aa", r#""#, rtok("", r"aa\\\aa"), r"aa\\\aa"), + (r#"aa\\"\aa"#, r#""\aa"#, rtok("", r"aa\\"), r"aa\\"), (r#"aa\\\"\aa"#, r#""#, rtok("", r#"aa\\\"\aa"#), r#"aa\\"\aa"#), (r#"\"\""#, r#""#, rtok("", r#"\"\""#), r#""""#), ]; @@ -301,12 +301,12 @@ pub mod test { ); // simple quote assert_eq!( - unescape(Span::new_extra(r#"Hello \'World\'"#, ""), '\''), + unescape(Span::new_extra(r"Hello \'World\'", ""), '\''), r#"Hello 'World'"#.to_string() ); assert_eq!( - unescape(Span::new_extra(r#"Hello \\\'World\\\'"#, ""), '\''), - r#"Hello \\'World\\'"#.to_string() + unescape(Span::new_extra(r"Hello \\\'World\\\'", ""), '\''), + r"Hello \\'World\\'".to_string() ); } @@ -335,19 +335,19 @@ pub mod test { ("\"cha'nnel\"", "cha'nnel", false), ("I'm tamo", "I", false), // escaped thing but not quote - (r#""\\""#, r#"\"#, true), - (r#""\\\\\\""#, r#"\\\"#, true), - (r#""aa\\aa""#, r#"aa\aa"#, true), + (r#""\\""#, r"\", true), + (r#""\\\\\\""#, r"\\\", true), + (r#""aa\\aa""#, r"aa\aa", true), // with double quote (r#""Hello \"world\"""#, r#"Hello "world""#, true), (r#""Hello \\\"world\\\"""#, r#"Hello \"world\""#, true), (r#""I'm \"super\" tamo""#, r#"I'm "super" tamo"#, true), (r#""\"\"""#, r#""""#, true), // with simple quote - (r#"'Hello \'world\''"#, r#"Hello 'world'"#, true), - (r#"'Hello \\\'world\\\''"#, r#"Hello \'world\'"#, true), + (r"'Hello \'world\''", r#"Hello 'world'"#, true), + (r"'Hello \\\'world\\\''", r"Hello \'world\'", true), (r#"'I\'m "super" tamo'"#, r#"I'm "super" tamo"#, true), - (r#"'\'\''"#, r#"''"#, true), + (r"'\'\''", r#"''"#, true), ]; for (input, expected, escaped) in test_case { diff --git a/index-scheduler/src/batch.rs b/index-scheduler/src/batch.rs index d53dbf001..c1d9a506b 100644 --- a/index-scheduler/src/batch.rs +++ b/index-scheduler/src/batch.rs @@ -1482,7 +1482,6 @@ impl IndexScheduler { self.all_tasks.delete(wtxn, &task)?; } for canceled_by in affected_canceled_by { - let canceled_by = canceled_by; if let Some(mut tasks) = self.canceled_by.get(wtxn, &canceled_by)? { tasks -= &to_delete_tasks; if tasks.is_empty() { diff --git a/index-scheduler/src/lib.rs b/index-scheduler/src/lib.rs index 545409b81..446db8eae 100644 --- a/index-scheduler/src/lib.rs +++ b/index-scheduler/src/lib.rs @@ -730,7 +730,7 @@ impl IndexScheduler { if let Some(canceled_by) = &query.canceled_by { let mut all_canceled_tasks = RoaringBitmap::new(); for cancel_task_uid in canceled_by { - if let Some(canceled_by_uid) = self.canceled_by.get(rtxn, &*cancel_task_uid)? { + if let Some(canceled_by_uid) = self.canceled_by.get(rtxn, cancel_task_uid)? { all_canceled_tasks |= canceled_by_uid; } } @@ -1509,8 +1509,8 @@ impl<'a> Dump<'a> { } } - self.statuses.entry(task.status).or_insert(RoaringBitmap::new()).insert(task.uid); - self.kinds.entry(task.kind.as_kind()).or_insert(RoaringBitmap::new()).insert(task.uid); + self.statuses.entry(task.status).or_default().insert(task.uid); + self.kinds.entry(task.kind.as_kind()).or_default().insert(task.uid); Ok(task) } diff --git a/index-scheduler/src/utils.rs b/index-scheduler/src/utils.rs index 59d8f8f52..9f6f90db2 100644 --- a/index-scheduler/src/utils.rs +++ b/index-scheduler/src/utils.rs @@ -337,8 +337,6 @@ impl IndexScheduler { let rtxn = self.env.read_txn().unwrap(); for task in self.all_tasks.iter(&rtxn).unwrap() { let (task_id, task) = task.unwrap(); - let task_id = task_id; - let task_index_uid = task.index_uid().map(ToOwned::to_owned); let Task { diff --git a/meilisearch/src/routes/indexes/settings.rs b/meilisearch/src/routes/indexes/settings.rs index 3921b535e..9fe94cad2 100644 --- a/meilisearch/src/routes/indexes/settings.rs +++ b/meilisearch/src/routes/indexes/settings.rs @@ -1,3 +1,5 @@ +#![allow(clippy::redundant_closure_call)] + use actix_web::web::Data; use actix_web::{web, HttpRequest, HttpResponse}; use deserr::actix_web::AwebJson; diff --git a/meilisearch/src/routes/multi_search.rs b/meilisearch/src/routes/multi_search.rs index 3a028022a..2e1297038 100644 --- a/meilisearch/src/routes/multi_search.rs +++ b/meilisearch/src/routes/multi_search.rs @@ -46,7 +46,7 @@ pub async fn multi_search_with_post( // Explicitly expect a `(ResponseError, usize)` for the error type rather than `ResponseError` only, // so that `?` doesn't work if it doesn't use `with_index`, ensuring that it is not forgotten in case of code // changes. - let search_results: Result<_, (ResponseError, usize)> = (|| { + let search_results: Result<_, (ResponseError, usize)> = { async { let mut search_results = Vec::with_capacity(queries.len()); for (query_index, (index_uid, mut query)) in @@ -88,7 +88,7 @@ pub async fn multi_search_with_post( } Ok(search_results) } - })() + } .await; if search_results.is_ok() { diff --git a/meilisearch/tests/search/distinct.rs b/meilisearch/tests/search/distinct.rs index 14ce88da2..aea98215d 100644 --- a/meilisearch/tests/search/distinct.rs +++ b/meilisearch/tests/search/distinct.rs @@ -4,7 +4,7 @@ use once_cell::sync::Lazy; use crate::common::{Server, Value}; use crate::json; -pub(self) static DOCUMENTS: Lazy = Lazy::new(|| { +static DOCUMENTS: Lazy = Lazy::new(|| { json!([ { "id": 1, @@ -107,8 +107,8 @@ pub(self) static DOCUMENTS: Lazy = Lazy::new(|| { ]) }); -pub(self) static DOCUMENT_PRIMARY_KEY: &str = "id"; -pub(self) static DOCUMENT_DISTINCT_KEY: &str = "product_id"; +static DOCUMENT_PRIMARY_KEY: &str = "id"; +static DOCUMENT_DISTINCT_KEY: &str = "product_id"; /// testing: https://github.com/meilisearch/meilisearch/issues/4078 #[actix_rt::test] diff --git a/meilisearch/tests/search/facet_search.rs b/meilisearch/tests/search/facet_search.rs index 1b06f1b98..8c1229f1a 100644 --- a/meilisearch/tests/search/facet_search.rs +++ b/meilisearch/tests/search/facet_search.rs @@ -4,7 +4,7 @@ use once_cell::sync::Lazy; use crate::common::{Server, Value}; use crate::json; -pub(self) static DOCUMENTS: Lazy = Lazy::new(|| { +static DOCUMENTS: Lazy = Lazy::new(|| { json!([ { "title": "Shazam!", diff --git a/meilisearch/tests/search/geo.rs b/meilisearch/tests/search/geo.rs index 67a4ca7df..5c6bb78a1 100644 --- a/meilisearch/tests/search/geo.rs +++ b/meilisearch/tests/search/geo.rs @@ -4,7 +4,7 @@ use once_cell::sync::Lazy; use crate::common::{Server, Value}; use crate::json; -pub(self) static DOCUMENTS: Lazy = Lazy::new(|| { +static DOCUMENTS: Lazy = Lazy::new(|| { json!([ { "id": 1, diff --git a/meilisearch/tests/search/mod.rs b/meilisearch/tests/search/mod.rs index 0cf322401..00678f7d4 100644 --- a/meilisearch/tests/search/mod.rs +++ b/meilisearch/tests/search/mod.rs @@ -15,7 +15,7 @@ use once_cell::sync::Lazy; use crate::common::{Server, Value}; use crate::json; -pub(self) static DOCUMENTS: Lazy = Lazy::new(|| { +static DOCUMENTS: Lazy = Lazy::new(|| { json!([ { "title": "Shazam!", @@ -40,7 +40,7 @@ pub(self) static DOCUMENTS: Lazy = Lazy::new(|| { ]) }); -pub(self) static NESTED_DOCUMENTS: Lazy = Lazy::new(|| { +static NESTED_DOCUMENTS: Lazy = Lazy::new(|| { json!([ { "id": 852, diff --git a/milli/src/external_documents_ids.rs b/milli/src/external_documents_ids.rs index 7e0f795a4..361617826 100644 --- a/milli/src/external_documents_ids.rs +++ b/milli/src/external_documents_ids.rs @@ -29,7 +29,7 @@ impl ExternalDocumentsIds { } pub fn get>(&self, rtxn: &RoTxn, external_id: A) -> heed::Result> { - Ok(self.0.get(rtxn, external_id.as_ref())?) + self.0.get(rtxn, external_id.as_ref()) } /// An helper function to debug this type, returns an `HashMap` of both, diff --git a/milli/src/search/new/geo_sort.rs b/milli/src/search/new/geo_sort.rs index bd9546048..0cefc19c2 100644 --- a/milli/src/search/new/geo_sort.rs +++ b/milli/src/search/new/geo_sort.rs @@ -163,7 +163,7 @@ impl GeoSort { // computing the distance between two points is expensive thus we cache the result documents .sort_by_cached_key(|(_, p)| distance_between_two_points(&self.point, p) as usize); - self.cached_sorted_docids.extend(documents.into_iter()); + self.cached_sorted_docids.extend(documents); }; Ok(()) diff --git a/milli/src/search/new/interner.rs b/milli/src/search/new/interner.rs index c2d325a86..e94be2e77 100644 --- a/milli/src/search/new/interner.rs +++ b/milli/src/search/new/interner.rs @@ -228,7 +228,7 @@ impl Ord for Interned { impl PartialOrd for Interned { fn partial_cmp(&self, other: &Self) -> Option { - self.idx.partial_cmp(&other.idx) + Some(self.cmp(other)) } } @@ -241,7 +241,7 @@ impl PartialEq for Interned { } impl Clone for Interned { fn clone(&self) -> Self { - Self { idx: self.idx, _phantom: PhantomData } + *self } } diff --git a/milli/src/search/new/mod.rs b/milli/src/search/new/mod.rs index 60386258e..eaf55ccbb 100644 --- a/milli/src/search/new/mod.rs +++ b/milli/src/search/new/mod.rs @@ -607,7 +607,8 @@ fn check_sort_criteria(ctx: &SearchContext, sort_criteria: Option<&Vec> field: field.to_string(), valid_fields, hidden_fields, - })?; + } + .into()); } Member::Geo(_) if !sortable_fields.contains("_geo") => { let (valid_fields, hidden_fields) = @@ -617,7 +618,8 @@ fn check_sort_criteria(ctx: &SearchContext, sort_criteria: Option<&Vec> field: "_geo".to_string(), valid_fields, hidden_fields, - })?; + } + .into()); } _ => (), } diff --git a/milli/src/search/new/query_term/mod.rs b/milli/src/search/new/query_term/mod.rs index 72a427379..6760c8be7 100644 --- a/milli/src/search/new/query_term/mod.rs +++ b/milli/src/search/new/query_term/mod.rs @@ -175,7 +175,7 @@ impl QueryTermSubset { pub fn use_prefix_db(&self, ctx: &SearchContext) -> Option { let original = ctx.term_interner.get(self.original); - let Some(use_prefix_db) = original.zero_typo.use_prefix_db else { return None }; + let use_prefix_db = original.zero_typo.use_prefix_db?; let word = match &self.zero_typo_subset { NTypoTermSubset::All => Some(use_prefix_db), NTypoTermSubset::Subset { words, phrases: _ } => { diff --git a/milli/src/search/new/tests/attribute_fid.rs b/milli/src/search/new/tests/attribute_fid.rs index 09e52a394..38225404c 100644 --- a/milli/src/search/new/tests/attribute_fid.rs +++ b/milli/src/search/new/tests/attribute_fid.rs @@ -124,8 +124,7 @@ fn test_attribute_fid_simple() { s.query("the quick brown fox jumps over the lazy dog"); s.scoring_strategy(crate::score_details::ScoringStrategy::Detailed); let SearchResult { documents_ids, document_scores, .. } = s.execute().unwrap(); - let document_ids_scores: Vec<_> = - documents_ids.iter().zip(document_scores.into_iter()).collect(); + let document_ids_scores: Vec<_> = documents_ids.iter().zip(document_scores).collect(); insta::assert_snapshot!(format!("{document_ids_scores:#?}")); } @@ -142,7 +141,6 @@ fn test_attribute_fid_ngrams() { let SearchResult { documents_ids, document_scores, .. } = s.execute().unwrap(); - let document_ids_scores: Vec<_> = - documents_ids.iter().zip(document_scores.into_iter()).collect(); + let document_ids_scores: Vec<_> = documents_ids.iter().zip(document_scores).collect(); insta::assert_snapshot!(format!("{document_ids_scores:#?}")); } diff --git a/milli/src/search/new/tests/attribute_position.rs b/milli/src/search/new/tests/attribute_position.rs index 1513528ec..68c5de540 100644 --- a/milli/src/search/new/tests/attribute_position.rs +++ b/milli/src/search/new/tests/attribute_position.rs @@ -141,8 +141,7 @@ fn test_attribute_position_simple() { let SearchResult { documents_ids, document_scores, .. } = s.execute().unwrap(); - let document_ids_scores: Vec<_> = - documents_ids.iter().zip(document_scores.into_iter()).collect(); + let document_ids_scores: Vec<_> = documents_ids.iter().zip(document_scores).collect(); insta::assert_snapshot!(format!("{document_ids_scores:#?}")); } #[test] @@ -158,8 +157,7 @@ fn test_attribute_position_repeated() { let SearchResult { documents_ids, document_scores, .. } = s.execute().unwrap(); - let document_ids_scores: Vec<_> = - documents_ids.iter().zip(document_scores.into_iter()).collect(); + let document_ids_scores: Vec<_> = documents_ids.iter().zip(document_scores).collect(); insta::assert_snapshot!(format!("{document_ids_scores:#?}")); } @@ -176,8 +174,7 @@ fn test_attribute_position_different_fields() { let SearchResult { documents_ids, document_scores, .. } = s.execute().unwrap(); - let document_ids_scores: Vec<_> = - documents_ids.iter().zip(document_scores.into_iter()).collect(); + let document_ids_scores: Vec<_> = documents_ids.iter().zip(document_scores).collect(); insta::assert_snapshot!(format!("{document_ids_scores:#?}")); } @@ -194,7 +191,6 @@ fn test_attribute_position_ngrams() { let SearchResult { documents_ids, document_scores, .. } = s.execute().unwrap(); - let document_ids_scores: Vec<_> = - documents_ids.iter().zip(document_scores.into_iter()).collect(); + let document_ids_scores: Vec<_> = documents_ids.iter().zip(document_scores).collect(); insta::assert_snapshot!(format!("{document_ids_scores:#?}")); } diff --git a/milli/src/search/new/tests/exactness.rs b/milli/src/search/new/tests/exactness.rs index a486342c1..c52006e3d 100644 --- a/milli/src/search/new/tests/exactness.rs +++ b/milli/src/search/new/tests/exactness.rs @@ -478,8 +478,7 @@ fn test_exactness_simple_ordered() { let SearchResult { documents_ids, document_scores, .. } = s.execute().unwrap(); - let document_ids_scores: Vec<_> = - documents_ids.iter().zip(document_scores.into_iter()).collect(); + let document_ids_scores: Vec<_> = documents_ids.iter().zip(document_scores).collect(); insta::assert_snapshot!(format!("{document_ids_scores:#?}")); let texts = collect_field_values(&index, &txn, "text", &documents_ids); @@ -511,8 +510,7 @@ fn test_exactness_simple_reversed() { let SearchResult { documents_ids, document_scores, .. } = s.execute().unwrap(); - let document_ids_scores: Vec<_> = - documents_ids.iter().zip(document_scores.into_iter()).collect(); + let document_ids_scores: Vec<_> = documents_ids.iter().zip(document_scores).collect(); insta::assert_snapshot!(format!("{document_ids_scores:#?}")); let texts = collect_field_values(&index, &txn, "text", &documents_ids); @@ -535,8 +533,7 @@ fn test_exactness_simple_reversed() { let SearchResult { documents_ids, document_scores, .. } = s.execute().unwrap(); - let document_ids_scores: Vec<_> = - documents_ids.iter().zip(document_scores.into_iter()).collect(); + let document_ids_scores: Vec<_> = documents_ids.iter().zip(document_scores).collect(); insta::assert_snapshot!(format!("{document_ids_scores:#?}")); let texts = collect_field_values(&index, &txn, "text", &documents_ids); @@ -566,8 +563,7 @@ fn test_exactness_simple_random() { let SearchResult { documents_ids, document_scores, .. } = s.execute().unwrap(); - let document_ids_scores: Vec<_> = - documents_ids.iter().zip(document_scores.into_iter()).collect(); + let document_ids_scores: Vec<_> = documents_ids.iter().zip(document_scores).collect(); insta::assert_snapshot!(format!("{document_ids_scores:#?}")); let texts = collect_field_values(&index, &txn, "text", &documents_ids); @@ -596,8 +592,7 @@ fn test_exactness_attribute_starts_with_simple() { let SearchResult { documents_ids, document_scores, .. } = s.execute().unwrap(); - let document_ids_scores: Vec<_> = - documents_ids.iter().zip(document_scores.into_iter()).collect(); + let document_ids_scores: Vec<_> = documents_ids.iter().zip(document_scores).collect(); insta::assert_snapshot!(format!("{document_ids_scores:#?}")); let texts = collect_field_values(&index, &txn, "text", &documents_ids); @@ -623,8 +618,7 @@ fn test_exactness_attribute_starts_with_phrase() { let SearchResult { documents_ids, document_scores, .. } = s.execute().unwrap(); - let document_ids_scores: Vec<_> = - documents_ids.iter().zip(document_scores.into_iter()).collect(); + let document_ids_scores: Vec<_> = documents_ids.iter().zip(document_scores).collect(); insta::assert_snapshot!(format!("{document_ids_scores:#?}")); let texts = collect_field_values(&index, &txn, "text", &documents_ids); @@ -644,8 +638,7 @@ fn test_exactness_attribute_starts_with_phrase() { let SearchResult { documents_ids, document_scores, .. } = s.execute().unwrap(); - let document_ids_scores: Vec<_> = - documents_ids.iter().zip(document_scores.into_iter()).collect(); + let document_ids_scores: Vec<_> = documents_ids.iter().zip(document_scores).collect(); insta::assert_snapshot!(format!("{document_ids_scores:#?}")); let texts = collect_field_values(&index, &txn, "text", &documents_ids); @@ -674,8 +667,7 @@ fn test_exactness_all_candidates_with_typo() { let SearchResult { documents_ids, document_scores, .. } = s.execute().unwrap(); - let document_ids_scores: Vec<_> = - documents_ids.iter().zip(document_scores.into_iter()).collect(); + let document_ids_scores: Vec<_> = documents_ids.iter().zip(document_scores).collect(); insta::assert_snapshot!(format!("{document_ids_scores:#?}")); let texts = collect_field_values(&index, &txn, "text", &documents_ids); @@ -711,8 +703,7 @@ fn test_exactness_after_words() { let SearchResult { documents_ids, document_scores, .. } = s.execute().unwrap(); - let document_ids_scores: Vec<_> = - documents_ids.iter().zip(document_scores.into_iter()).collect(); + let document_ids_scores: Vec<_> = documents_ids.iter().zip(document_scores).collect(); insta::assert_snapshot!(format!("{document_ids_scores:#?}")); let texts = collect_field_values(&index, &txn, "text", &documents_ids); @@ -760,8 +751,7 @@ fn test_words_after_exactness() { let SearchResult { documents_ids, document_scores, .. } = s.execute().unwrap(); - let document_ids_scores: Vec<_> = - documents_ids.iter().zip(document_scores.into_iter()).collect(); + let document_ids_scores: Vec<_> = documents_ids.iter().zip(document_scores).collect(); insta::assert_snapshot!(format!("{document_ids_scores:#?}")); insta::assert_snapshot!(format!("{documents_ids:?}"), @"[19, 9, 18, 8, 17, 16, 6, 7, 15, 5, 14, 4, 13, 3, 12, 2, 1, 11]"); let texts = collect_field_values(&index, &txn, "text", &documents_ids); @@ -809,8 +799,7 @@ fn test_proximity_after_exactness() { let SearchResult { documents_ids, document_scores, .. } = s.execute().unwrap(); - let document_ids_scores: Vec<_> = - documents_ids.iter().zip(document_scores.into_iter()).collect(); + let document_ids_scores: Vec<_> = documents_ids.iter().zip(document_scores).collect(); insta::assert_snapshot!(format!("{document_ids_scores:#?}")); insta::assert_snapshot!(format!("{documents_ids:?}"), @"[2, 1, 0, 4, 5, 8, 7, 3, 6]"); @@ -847,8 +836,7 @@ fn test_proximity_after_exactness() { let SearchResult { documents_ids, document_scores, .. } = s.execute().unwrap(); - let document_ids_scores: Vec<_> = - documents_ids.iter().zip(document_scores.into_iter()).collect(); + let document_ids_scores: Vec<_> = documents_ids.iter().zip(document_scores).collect(); insta::assert_snapshot!(format!("{document_ids_scores:#?}")); insta::assert_snapshot!(format!("{documents_ids:?}"), @"[0, 1, 2]"); let texts = collect_field_values(&index, &txn, "text", &documents_ids); @@ -881,8 +869,7 @@ fn test_exactness_followed_by_typo_prefer_no_typo_prefix() { let SearchResult { documents_ids, document_scores, .. } = s.execute().unwrap(); - let document_ids_scores: Vec<_> = - documents_ids.iter().zip(document_scores.into_iter()).collect(); + let document_ids_scores: Vec<_> = documents_ids.iter().zip(document_scores).collect(); insta::assert_snapshot!(format!("{document_ids_scores:#?}")); insta::assert_snapshot!(format!("{documents_ids:?}"), @"[2, 1, 0, 4, 3]"); let texts = collect_field_values(&index, &txn, "text", &documents_ids); @@ -917,8 +904,7 @@ fn test_typo_followed_by_exactness() { let SearchResult { documents_ids, document_scores, .. } = s.execute().unwrap(); - let document_ids_scores: Vec<_> = - documents_ids.iter().zip(document_scores.into_iter()).collect(); + let document_ids_scores: Vec<_> = documents_ids.iter().zip(document_scores).collect(); insta::assert_snapshot!(format!("{document_ids_scores:#?}")); insta::assert_snapshot!(format!("{documents_ids:?}"), @"[1, 0, 4, 3]"); let texts = collect_field_values(&index, &txn, "text", &documents_ids); diff --git a/milli/src/update/facet/mod.rs b/milli/src/update/facet/mod.rs index 166410d0d..991178903 100644 --- a/milli/src/update/facet/mod.rs +++ b/milli/src/update/facet/mod.rs @@ -146,7 +146,7 @@ impl<'i> FacetsUpdate<'i> { self.index.set_updated_at(wtxn, &OffsetDateTime::now_utc())?; // See self::comparison_bench::benchmark_facet_indexing - if self.delta_data.len() >= (self.database.len(wtxn)? as u64 / 50) { + if self.delta_data.len() >= (self.database.len(wtxn)? / 50) { let field_ids = self.index.faceted_fields_ids(wtxn)?.iter().copied().collect::>(); let bulk_update = FacetsUpdateBulk::new( diff --git a/milli/src/update/index_documents/extract/extract_docid_word_positions.rs b/milli/src/update/index_documents/extract/extract_docid_word_positions.rs index 303b64271..a6bbf939a 100644 --- a/milli/src/update/index_documents/extract/extract_docid_word_positions.rs +++ b/milli/src/update/index_documents/extract/extract_docid_word_positions.rs @@ -309,8 +309,7 @@ fn tokens_from_document<'a>( // if a language has been detected for the token, we update the counter. if let Some(language) = token.language { let script = token.script; - let entry = - script_language_word_count.entry(script).or_insert_with(Vec::new); + let entry = script_language_word_count.entry(script).or_default(); match entry.iter_mut().find(|(l, _)| *l == language) { Some((_, n)) => *n += 1, None => entry.push((language, 1)),