From 4d5005b01a0b2395b5f41a1407604decf0479f10 Mon Sep 17 00:00:00 2001 From: Tamo Date: Wed, 10 Jul 2024 00:05:43 +0200 Subject: [PATCH] make clippy happy --- meilisearch/src/routes/indexes/documents.rs | 2 ++ meilisearch/src/search.rs | 2 ++ .../roaring_bitmap_length/roaring_bitmap_len_codec.rs | 2 +- milli/src/search/new/query_graph.rs | 2 +- milli/src/update/available_documents_ids.rs | 8 ++++---- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/meilisearch/src/routes/indexes/documents.rs b/meilisearch/src/routes/indexes/documents.rs index 1f413ec7d..7c6cbc85d 100644 --- a/meilisearch/src/routes/indexes/documents.rs +++ b/meilisearch/src/routes/indexes/documents.rs @@ -615,6 +615,8 @@ fn some_documents<'a, 't: 'a>( document.remove("_vectors"); } RetrieveVectors::Retrieve => { + // Clippy is simply wrong + #[allow(clippy::manual_unwrap_or_default)] let mut vectors = match document.remove("_vectors") { Some(Value::Object(map)) => map, _ => Default::default(), diff --git a/meilisearch/src/search.rs b/meilisearch/src/search.rs index 375060889..2bc87d2ba 100644 --- a/meilisearch/src/search.rs +++ b/meilisearch/src/search.rs @@ -1150,6 +1150,8 @@ fn make_hits( permissive_json_pointer::select_values(&displayed_document, attributes_to_retrieve); if retrieve_vectors == RetrieveVectors::Retrieve { + // Clippy is wrong + #[allow(clippy::manual_unwrap_or_default)] let mut vectors = match document.remove("_vectors") { Some(Value::Object(map)) => map, _ => Default::default(), diff --git a/milli/src/heed_codec/roaring_bitmap_length/roaring_bitmap_len_codec.rs b/milli/src/heed_codec/roaring_bitmap_length/roaring_bitmap_len_codec.rs index 578cb31e2..37567e956 100644 --- a/milli/src/heed_codec/roaring_bitmap_length/roaring_bitmap_len_codec.rs +++ b/milli/src/heed_codec/roaring_bitmap_length/roaring_bitmap_len_codec.rs @@ -25,7 +25,7 @@ impl RoaringBitmapLenCodec { } }; - if size > u16::max_value() as usize + 1 { + if size > u16::MAX as usize + 1 { return Err(io::Error::new(io::ErrorKind::Other, "size is greater than supported")); } diff --git a/milli/src/search/new/query_graph.rs b/milli/src/search/new/query_graph.rs index cda767d75..5749981d7 100644 --- a/milli/src/search/new/query_graph.rs +++ b/milli/src/search/new/query_graph.rs @@ -316,7 +316,7 @@ impl QueryGraph { term_docids .into_iter() .map(|(idx, docids)| match docids.len() { - 0 => (idx, u64::max_value()), + 0 => (idx, u64::MAX), frequency => (idx, frequency), }) .collect() diff --git a/milli/src/update/available_documents_ids.rs b/milli/src/update/available_documents_ids.rs index f460693ba..3b05c5d6e 100644 --- a/milli/src/update/available_documents_ids.rs +++ b/milli/src/update/available_documents_ids.rs @@ -15,7 +15,7 @@ impl AvailableDocumentsIds { available -= docids; let iter = match last_id.checked_add(1) { - Some(id) => id..=u32::max_value(), + Some(id) => id..=u32::MAX, #[allow(clippy::reversed_empty_ranges)] None => 1..=0, // empty range iterator }; @@ -24,7 +24,7 @@ impl AvailableDocumentsIds { } None => { let empty = RoaringBitmap::new().into_iter(); - AvailableDocumentsIds { iter: empty.chain(0..=u32::max_value()) } + AvailableDocumentsIds { iter: empty.chain(0..=u32::MAX) } } } } @@ -46,7 +46,7 @@ mod tests { fn empty() { let base = RoaringBitmap::new(); let left = AvailableDocumentsIds::from_documents_ids(&base); - let right = 0..=u32::max_value(); + let right = 0..=u32::MAX; left.zip(right).take(500).for_each(|(l, r)| assert_eq!(l, r)); } @@ -59,7 +59,7 @@ mod tests { base.insert(405); let left = AvailableDocumentsIds::from_documents_ids(&base); - let right = (0..=u32::max_value()).filter(|&n| n != 0 && n != 10 && n != 100 && n != 405); + let right = (0..=u32::MAX).filter(|&n| n != 0 && n != 10 && n != 100 && n != 405); left.zip(right).take(500).for_each(|(l, r)| assert_eq!(l, r)); } }