From 4a3169011db4a6c8ababa1cba0456475ba6732c7 Mon Sep 17 00:00:00 2001 From: Paul Masurel Date: Sat, 20 Aug 2022 13:01:33 +0200 Subject: [PATCH] clippy (#1452) --- bitpacker/src/blocked_bitpacker.rs | 10 ++++++---- query-grammar/src/lib.rs | 2 ++ src/lib.rs | 1 + src/query/query_parser/query_parser.rs | 2 +- src/query/union.rs | 1 - 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/bitpacker/src/blocked_bitpacker.rs b/bitpacker/src/blocked_bitpacker.rs index 21cc58d7f..bfe958e76 100644 --- a/bitpacker/src/blocked_bitpacker.rs +++ b/bitpacker/src/blocked_bitpacker.rs @@ -58,6 +58,10 @@ fn metadata_test() { assert_eq!(meta.num_bits(), 6); } +fn mem_usage(items: &Vec) -> usize { + items.capacity() * std::mem::size_of::() +} + impl BlockedBitpacker { pub fn new() -> Self { let mut compressed_blocks = vec![]; @@ -73,10 +77,8 @@ impl BlockedBitpacker { pub fn mem_usage(&self) -> usize { std::mem::size_of::() + self.compressed_blocks.capacity() - + self.offset_and_bits.capacity() - * std::mem::size_of_val(&self.offset_and_bits.get(0).cloned().unwrap_or_default()) - + self.buffer.capacity() - * std::mem::size_of_val(&self.buffer.get(0).cloned().unwrap_or_default()) + + mem_usage(&self.offset_and_bits) + + mem_usage(&self.buffer) } #[inline] diff --git a/query-grammar/src/lib.rs b/query-grammar/src/lib.rs index bd68bcc4e..9b1e4007e 100644 --- a/query-grammar/src/lib.rs +++ b/query-grammar/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::derive_partial_eq_without_eq)] + mod occur; mod query_grammar; mod user_input_ast; diff --git a/src/lib.rs b/src/lib.rs index a320404bb..dbcd94f84 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,6 +11,7 @@ #![doc(test(attr(allow(unused_variables), deny(warnings))))] #![warn(missing_docs)] #![allow(clippy::len_without_is_empty)] +#![allow(clippy::derive_partial_eq_without_eq)] //! # `tantivy` //! diff --git a/src/query/query_parser/query_parser.rs b/src/query/query_parser/query_parser.rs index f9ce79254..e399b2118 100644 --- a/src/query/query_parser/query_parser.rs +++ b/src/query/query_parser/query_parser.rs @@ -184,7 +184,7 @@ pub struct QueryParser { fn all_negative(ast: &LogicalAst) -> bool { match ast { LogicalAst::Leaf(_) => false, - LogicalAst::Boost(ref child_ast, _) => all_negative(&*child_ast), + LogicalAst::Boost(ref child_ast, _) => all_negative(child_ast), LogicalAst::Clause(children) => children .iter() .all(|(ref occur, child)| (*occur == Occur::MustNot) || all_negative(child)), diff --git a/src/query/union.rs b/src/query/union.rs index 06ffb0ab3..9b56f5339 100644 --- a/src/query/union.rs +++ b/src/query/union.rs @@ -179,7 +179,6 @@ where // The target is outside of the buffered horizon. // advance all docsets to a doc >= to the target. - #[cfg_attr(feature = "cargo-clippy", allow(clippy::clippy::collapsible_if))] unordered_drain_filter(&mut self.docsets, |docset| { if docset.doc() < target { docset.seek(target);