diff --git a/Cargo.lock b/Cargo.lock index 07050b3ce1..210a1265b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2942,17 +2942,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "generic-tests" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9ff6d6584f4f6fa911d5e07856abf1a48dc5599b3734f2eaea130f2c3baa989" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.118", -] - [[package]] name = "geo" version = "0.33.1" @@ -7093,7 +7082,6 @@ dependencies = [ "indexmap 2.14.0", "indicatif", "integer-encoding", - "io-uring", "io_bridge_object_store", "itertools 0.15.0", "log", @@ -7651,7 +7639,6 @@ dependencies = [ "dataset", "duplicate", "fs-err", - "generic-tests", "half 2.7.1", "indicatif", "itertools 0.15.0", @@ -8572,7 +8559,6 @@ dependencies = [ "schnellru", "static_assertions", "strum", - "tokio", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index e9d2053613..9be53933f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -229,7 +229,6 @@ fs-err = { version = "3.3.0", features = ["tokio"] } fs_extra = "1.3.0" futures = "0.3.32" futures-util = "0.3.32" -generic-tests = "0.1.3" half = { version = "2.7.1", features = [ "alloc", "bytemuck", @@ -259,7 +258,6 @@ ph = "0.8.5" pprof = { version = "0.15.0", features = ["flamegraph", "prost-codec"] } proptest = { version = "1.11.0", default-features = false, features = ["std"] } prost = "0.14.0" -prost-build = { version = "0.14.0", features = ["cleanup-markdown"] } prost-types = "0.14.0" prost-wkt-types = "0.7" prost-for-raft = { package = "prost", version = "=0.11.9" } # version of prost used by raft diff --git a/lib/bm25/src/lib.rs b/lib/bm25/src/lib.rs index d53fdc012b..5f36247b4c 100644 --- a/lib/bm25/src/lib.rs +++ b/lib/bm25/src/lib.rs @@ -113,10 +113,6 @@ impl Bm25 { Ok(Self { params }) } - pub fn params(&self) -> &Bm25Params { - &self.params - } - /// Embed a search query: each unique token gets weight `1.0`. Indices are /// returned sorted (post-dedup invariant). pub fn embed_query(&self, tokens: &[Cow<'_, str>]) -> SparseEmbedding { diff --git a/lib/collection/Cargo.toml b/lib/collection/Cargo.toml index 84adcb8ddc..3936af52d5 100644 --- a/lib/collection/Cargo.toml +++ b/lib/collection/Cargo.toml @@ -22,6 +22,7 @@ criterion = { workspace = true } fs-err = { workspace = true, features = ["debug"] } proptest = { workspace = true } rand_distr = { workspace = true } +rmp-serde = { workspace = true } rstest = { workspace = true } tar = { workspace = true } approx = "0.5.1" @@ -43,7 +44,6 @@ rand = { workspace = true } thiserror = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } -rmp-serde = { workspace = true } ordered-float = { workspace = true } hashring = "0.3.6" tinyvec = { workspace = true } diff --git a/lib/collection/benches/batch_query_bench.rs b/lib/collection/benches/batch_query_bench.rs index 9ee1f1b7f2..51e181994d 100644 --- a/lib/collection/benches/batch_query_bench.rs +++ b/lib/collection/benches/batch_query_bench.rs @@ -32,9 +32,6 @@ use tempfile::{Builder, TempDir}; use tokio::runtime::Runtime; use tokio::sync::RwLock; -#[cfg(not(target_os = "windows"))] -mod prof; - fn setup() -> (TempDir, LocalShard, Runtime) { let storage_dir = Builder::new().prefix("storage").tempdir().unwrap(); diff --git a/lib/collection/benches/batch_search_bench.rs b/lib/collection/benches/batch_search_bench.rs index f29f70f11c..bb8d8614ac 100644 --- a/lib/collection/benches/batch_search_bench.rs +++ b/lib/collection/benches/batch_search_bench.rs @@ -26,9 +26,6 @@ use tempfile::Builder; use tokio::runtime::Runtime; use tokio::sync::RwLock; -#[cfg(not(target_os = "windows"))] -mod prof; - fn create_rnd_batch() -> CollectionUpdateOperations { let mut rng = rand::make_rng::(); let num_points = 2000; diff --git a/lib/collection/benches/hash_ring_bench.rs b/lib/collection/benches/hash_ring_bench.rs index c3f2e88c29..38c454b0b0 100644 --- a/lib/collection/benches/hash_ring_bench.rs +++ b/lib/collection/benches/hash_ring_bench.rs @@ -1,6 +1,3 @@ -#[cfg(not(target_os = "windows"))] -mod prof; - use collection::hash_ring::HashRing; use criterion::{Criterion, criterion_group, criterion_main}; use rand::RngExt; diff --git a/lib/collection/benches/prof.rs b/lib/collection/benches/prof.rs index a306a8cb1d..3f9eec1f20 100644 --- a/lib/collection/benches/prof.rs +++ b/lib/collection/benches/prof.rs @@ -47,7 +47,6 @@ pub struct FlamegraphProfiler<'a> { } impl FlamegraphProfiler<'_> { - #[allow(dead_code)] pub fn new(frequency: c_int) -> Self { FlamegraphProfiler { frequency, diff --git a/lib/collection/src/shards/transfer/mod.rs b/lib/collection/src/shards/transfer/mod.rs index dc561851b2..5ff7724e93 100644 --- a/lib/collection/src/shards/transfer/mod.rs +++ b/lib/collection/src/shards/transfer/mod.rs @@ -296,13 +296,6 @@ pub enum ShardTransferMethod { } impl ShardTransferMethod { - pub fn is_streaming(&self) -> bool { - match self { - Self::StreamRecords | Self::ReshardingStreamRecords => true, - Self::Snapshot | Self::WalDelta => false, - } - } - pub fn is_resharding(&self) -> bool { match self { Self::ReshardingStreamRecords => true, diff --git a/lib/common/common/src/sorted_slice.rs b/lib/common/common/src/sorted_slice.rs index 254cf6b271..8a9fb5f1ab 100644 --- a/lib/common/common/src/sorted_slice.rs +++ b/lib/common/common/src/sorted_slice.rs @@ -1,4 +1,4 @@ -use std::ops::{Deref, Range, RangeInclusive}; +use std::ops::Deref; pub struct SortedSlice<'a, T: PartialOrd>(&'a [T]); @@ -20,21 +20,6 @@ impl<'a, T: PartialOrd> SortedSlice<'a, T> { } } -impl<'a, T: PartialOrd + Copy> SortedSlice<'a, T> { - pub fn get_range_inclusive(&self) -> Option> { - let first = *self.first()?; - let last = *self.last()?; - Some(first..=last) - } -} - -impl<'a> SortedSlice<'a, u32> { - pub fn range_u64(&self) -> Option> { - let (start, end) = self.get_range_inclusive()?.into_inner(); - Some(u64::from(start)..u64::from(end) + 1) - } -} - impl Deref for SortedSlice<'_, T> { type Target = [T]; diff --git a/lib/edge/ffi/src/filter.rs b/lib/edge/ffi/src/filter.rs index 21d01407b7..f41a0afe21 100644 --- a/lib/edge/ffi/src/filter.rs +++ b/lib/edge/ffi/src/filter.rs @@ -745,7 +745,7 @@ fn filter_to_segment(f: Filter, depth: u32) -> Result { diff --git a/lib/edge/ffi/src/ops/formula.rs b/lib/edge/ffi/src/ops/formula.rs index c6d421cad7..84fa9eccfc 100644 --- a/lib/edge/ffi/src/ops/formula.rs +++ b/lib/edge/ffi/src/ops/formula.rs @@ -344,7 +344,7 @@ impl Expression { /// compiling until the constructor surface decision is recorded here. /// /// Never called; it exists only for the exhaustiveness check. -#[allow(dead_code)] +#[expect(dead_code)] fn assert_every_expression_is_mapped(e: ExpressionInternal) { match e { // [`Expression::constant`] diff --git a/lib/edge/ffi/src/ops/query.rs b/lib/edge/ffi/src/ops/query.rs index 435fc699b2..5595f95ef1 100644 --- a/lib/edge/ffi/src/ops/query.rs +++ b/lib/edge/ffi/src/ops/query.rs @@ -754,7 +754,7 @@ impl TryFrom for edge::QueryRequest { /// decision about the FFI surface. /// /// Never called; it exists only for the exhaustiveness check. -#[allow(dead_code)] +#[expect(dead_code)] fn assert_every_scoring_query_is_mapped(q: shard::query::ScoringQuery) { match q { shard::query::ScoringQuery::Vector(q) => match q { diff --git a/lib/edge/ffi/src/types.rs b/lib/edge/ffi/src/types.rs index 4fa03dd565..ed6a010c19 100644 --- a/lib/edge/ffi/src/types.rs +++ b/lib/edge/ffi/src/types.rs @@ -363,7 +363,7 @@ impl TryFrom for WithPayloadInterface { /// in [`crate::update`], [`crate::ops::query`], and [`crate::filter`]. /// /// Never called; it exists only for the exhaustiveness check. -#[allow(dead_code)] +#[expect(dead_code)] fn assert_every_selection_is_mapped(payload: WithPayloadInterface, vector: SegmentWithVector) { match payload { // [`WithPayload::Bool`] diff --git a/lib/edge/ffi/src/update.rs b/lib/edge/ffi/src/update.rs index d215889fc4..f0283e4184 100644 --- a/lib/edge/ffi/src/update.rs +++ b/lib/edge/ffi/src/update.rs @@ -741,7 +741,7 @@ impl From for PayloadSchemaType { /// here why it stays unexposed. /// /// Never called; it exists only for the exhaustiveness check. -#[allow(dead_code)] +#[expect(dead_code)] fn assert_every_update_operation_is_mapped(op: CollectionUpdateOperations) { match op { CollectionUpdateOperations::PointOperation(op) => match op { diff --git a/lib/edge/python/src/utils.rs b/lib/edge/python/src/utils.rs index d261bf4e5a..505670d2c4 100644 --- a/lib/edge/python/src/utils.rs +++ b/lib/edge/python/src/utils.rs @@ -13,14 +13,4 @@ impl PyEdgeShard { ))) } } - - pub fn get_shard_mut(&mut self) -> Result<&mut EdgeShard, PyError> { - if let Some(shard) = &mut self.0 { - Ok(shard) - } else { - Err(PyError::from(OperationError::service_error( - "Shard is not initialized", - ))) - } - } } diff --git a/lib/gpu/src/buffer.rs b/lib/gpu/src/buffer.rs index badbec8c62..296cf68bb2 100644 --- a/lib/gpu/src/buffer.rs +++ b/lib/gpu/src/buffer.rs @@ -169,20 +169,6 @@ impl Buffer { self.buffer_type } - /// Download a value from the buffer to the RAM. - pub fn download(&self, data: &mut T, offset: usize) -> GpuResult<()> - where - T: FromBytes + IntoBytes + ?Sized, - { - if self.buffer_type != BufferType::GpuToCpu { - return Err(GpuError::Other(DOWNLOAD_NOT_ALLOWED_ERROR.to_string())); - } - let data_bytes = data.as_mut_bytes(); - let end = checked_add(offset, data_bytes.len())?; - self.view(offset..end)?.copy_from_slice(data_bytes); - Ok(()) - } - /// Download a vector of `len` elements from the buffer to the RAM. pub fn download_vec(&self, offset: usize, len: usize) -> GpuResult> where diff --git a/lib/quantization/Cargo.toml b/lib/quantization/Cargo.toml index 77a8a24c86..0df90473c6 100644 --- a/lib/quantization/Cargo.toml +++ b/lib/quantization/Cargo.toml @@ -20,7 +20,6 @@ cc = { workspace = true } [dependencies] fs-err = { workspace = true } serde = { workspace = true } -serde_json = { workspace = true } permutation_iterator = "0.1.2" rand = { workspace = true } rayon = { workspace = true } @@ -39,6 +38,7 @@ criterion = { workspace = true } num_threads = "0.1.7" rand_distr = { workspace = true } rstest = { workspace = true } +serde_json = { workspace = true } tempfile = { workspace = true } [[bench]] diff --git a/lib/segment/Cargo.toml b/lib/segment/Cargo.toml index 8002e5487a..254e2fbb12 100644 --- a/lib/segment/Cargo.toml +++ b/lib/segment/Cargo.toml @@ -123,7 +123,6 @@ duplicate = "2.0.1" [target.'cfg(target_os = "linux")'.dependencies] cgroups-rs = "0.5" procfs = { version = "0.18", default-features = false } -io-uring = "0.7.12" [[bench]] name = "vector_search" diff --git a/lib/segment/benches/id_type_benchmark.rs b/lib/segment/benches/id_type_benchmark.rs index f2313d3b19..94fa554faf 100644 --- a/lib/segment/benches/id_type_benchmark.rs +++ b/lib/segment/benches/id_type_benchmark.rs @@ -1,6 +1,3 @@ -#[cfg(not(target_os = "windows"))] -mod prof; - use std::collections::{BTreeMap, HashMap}; use criterion::{Criterion, criterion_group, criterion_main}; diff --git a/lib/segment/benches/map_benchmark.rs b/lib/segment/benches/map_benchmark.rs index 0dd5d9380b..c2374b920a 100644 --- a/lib/segment/benches/map_benchmark.rs +++ b/lib/segment/benches/map_benchmark.rs @@ -1,6 +1,3 @@ -#[cfg(not(target_os = "windows"))] -mod prof; - use std::collections::{BTreeMap, HashMap}; use criterion::{Criterion, criterion_group, criterion_main}; diff --git a/lib/segment/benches/metrics.rs b/lib/segment/benches/metrics.rs index 84c1353834..6f4e061fa7 100644 --- a/lib/segment/benches/metrics.rs +++ b/lib/segment/benches/metrics.rs @@ -1,6 +1,3 @@ -#[cfg(not(target_os = "windows"))] -mod prof; - use criterion::{Criterion, criterion_group, criterion_main}; use half::f16; use rand::rngs::SmallRng; diff --git a/lib/segment/benches/prof.rs b/lib/segment/benches/prof.rs index a306a8cb1d..3f9eec1f20 100644 --- a/lib/segment/benches/prof.rs +++ b/lib/segment/benches/prof.rs @@ -47,7 +47,6 @@ pub struct FlamegraphProfiler<'a> { } impl FlamegraphProfiler<'_> { - #[allow(dead_code)] pub fn new(frequency: c_int) -> Self { FlamegraphProfiler { frequency, diff --git a/lib/segment/benches/serde_formats.rs b/lib/segment/benches/serde_formats.rs index 39042f2b4e..e9c810ba89 100644 --- a/lib/segment/benches/serde_formats.rs +++ b/lib/segment/benches/serde_formats.rs @@ -1,6 +1,3 @@ -#[cfg(not(target_os = "windows"))] -mod prof; - use criterion::{Criterion, criterion_group, criterion_main}; use itertools::Itertools; use segment::payload_json; diff --git a/lib/segment/src/common/flags/in_memory_bitvec_flags.rs b/lib/segment/src/common/flags/in_memory_bitvec_flags.rs index 4aa6e3a98f..17c79b045f 100644 --- a/lib/segment/src/common/flags/in_memory_bitvec_flags.rs +++ b/lib/segment/src/common/flags/in_memory_bitvec_flags.rs @@ -25,7 +25,6 @@ use crate::common::operation_error::{OperationError, OperationResult}; /// already folded in but not yet flushed to the flags file is never lost to a /// re-read. #[derive(Debug)] -#[allow(dead_code)] // pending: read-only vector storages will hold `deleted` as this pub struct InMemoryBitvecFlags { /// Flags, materialized on open and patched in place on live-reload. bitvec: BitVec, diff --git a/lib/segment/src/common/live_reload.rs b/lib/segment/src/common/live_reload.rs index 12e74f4aa5..d7664b41a8 100644 --- a/lib/segment/src/common/live_reload.rs +++ b/lib/segment/src/common/live_reload.rs @@ -27,7 +27,6 @@ use crate::common::operation_error::OperationResult; /// segment's id-tracker diff accumulated since the previous reload). /// /// [`UniversalRead`]: common::universal_io::UniversalRead -#[allow(dead_code)] pub(crate) trait LiveReload { /// Filesystem context (`S::Fs` of the backing [`UniversalRead`]) used to /// re-read on-disk state during a reload. diff --git a/lib/segment/src/common/operation_error.rs b/lib/segment/src/common/operation_error.rs index 6a4aab00b6..7b0a3586a2 100644 --- a/lib/segment/src/common/operation_error.rs +++ b/lib/segment/src/common/operation_error.rs @@ -146,33 +146,6 @@ impl OperationError { } } - /// Whether this error signals that all appendable segments are at `max_segment_size` capacity, - /// so the operation can be re-applied after provisioning a fresh appendable segment. - pub fn is_out_of_appendable_capacity(&self) -> bool { - match self { - Self::OutOfAppendableCapacity { .. } => true, - Self::WrongVectorDimension { .. } - | Self::MalformedVectorBlob { .. } - | Self::VectorNameNotExists { .. } - | Self::PointIdError { .. } - | Self::TypeError { .. } - | Self::TypeInferenceError { .. } - | Self::ServiceError { .. } - | Self::InconsistentStorage { .. } - | Self::FileNotFound { .. } - | Self::OutOfMemory { .. } - | Self::Cancelled { .. } - | Self::Timeout { .. } - | Self::ValidationError { .. } - | Self::WrongSparse - | Self::WrongMulti - | Self::MissingRangeIndexForOrderBy { .. } - | Self::MissingMapIndexForFacet { .. } - | Self::VariableTypeError { .. } - | Self::NonFiniteNumber { .. } => false, - } - } - pub fn timeout(timeout: Duration, operation: impl Into) -> Self { Self::Timeout { description: format!( diff --git a/lib/segment/src/data_types/named_vectors.rs b/lib/segment/src/data_types/named_vectors.rs index 308010ae20..82ad47f78c 100644 --- a/lib/segment/src/data_types/named_vectors.rs +++ b/lib/segment/src/data_types/named_vectors.rs @@ -263,10 +263,6 @@ impl<'a> NamedVectors<'a> { .insert(Cow::Borrowed(name), CowVector::from(vector)); } - pub fn remove_ref(&mut self, key: &VectorName) { - self.map.remove(key); - } - pub fn contains_key(&self, key: &VectorName) -> bool { self.map.contains_key(key) } diff --git a/lib/segment/src/id_tracker/format_detection.rs b/lib/segment/src/id_tracker/format_detection.rs index 41ddd3dbb7..3edaee3d2c 100644 --- a/lib/segment/src/id_tracker/format_detection.rs +++ b/lib/segment/src/id_tracker/format_detection.rs @@ -50,8 +50,4 @@ impl IdTrackerFormat { i2e_path(segment_path).is_file(), ) } - - pub fn is_mutable(self) -> bool { - matches!(self, Self::Mutable) - } } diff --git a/lib/segment/src/id_tracker/id_tracker_base/mod.rs b/lib/segment/src/id_tracker/id_tracker_base/mod.rs index 63bfaabcd9..0134155ca0 100644 --- a/lib/segment/src/id_tracker/id_tracker_base/mod.rs +++ b/lib/segment/src/id_tracker/id_tracker_base/mod.rs @@ -2,7 +2,6 @@ mod point_mappings_ref; mod tracker_enum; mod trait_def; -#[allow(dead_code)] pub mod read_only_tracker_enum; pub use point_mappings_ref::{PointMappingsGuard, PointMappingsRefEnum}; diff --git a/lib/segment/src/id_tracker/id_tracker_base/point_mappings_ref.rs b/lib/segment/src/id_tracker/id_tracker_base/point_mappings_ref.rs index 27e62bbb39..fd40ee525f 100644 --- a/lib/segment/src/id_tracker/id_tracker_base/point_mappings_ref.rs +++ b/lib/segment/src/id_tracker/id_tracker_base/point_mappings_ref.rs @@ -200,16 +200,6 @@ impl<'a, S: UniversalRead> PointMappingsRefEnum<'a, S> { } } - /// Iterate starting from a given ID, filtering deferred points using the - /// mapping's own threshold. Shorthand for - /// [`Self::iter_from_with_behavior`] with [`DeferredBehavior::VisibleOnly`]. - pub fn iter_from_visible( - self, - external_id: Option, - ) -> impl Iterator + 'a { - self.iter_from_with_behavior(external_id, DeferredBehavior::VisibleOnly) - } - /// Iterate over internal IDs in random order, filtering deferred points /// using the mapping's own threshold. Shorthand for /// [`Self::iter_random_with_behavior`] with [`DeferredBehavior::VisibleOnly`]. diff --git a/lib/segment/src/id_tracker/immutable_id_tracker/mod.rs b/lib/segment/src/id_tracker/immutable_id_tracker/mod.rs index 3eaa3d16fc..3aafbe4eac 100644 --- a/lib/segment/src/id_tracker/immutable_id_tracker/mod.rs +++ b/lib/segment/src/id_tracker/immutable_id_tracker/mod.rs @@ -5,7 +5,6 @@ mod versions_storage; #[cfg(test)] pub(super) mod tests; -#[allow(dead_code)] pub mod read_only; use std::fmt::Debug; diff --git a/lib/segment/src/id_tracker/mutable_id_tracker/mod.rs b/lib/segment/src/id_tracker/mutable_id_tracker/mod.rs index 3995af7f03..47a6d58494 100644 --- a/lib/segment/src/id_tracker/mutable_id_tracker/mod.rs +++ b/lib/segment/src/id_tracker/mutable_id_tracker/mod.rs @@ -5,7 +5,6 @@ mod versions_storage; #[cfg(test)] pub(super) mod tests; -#[allow(dead_code)] pub mod read_only; use std::collections::BTreeMap; diff --git a/lib/segment/src/index/field_index/facet_index.rs b/lib/segment/src/index/field_index/facet_index.rs index 29c4a73aa7..4802aab437 100644 --- a/lib/segment/src/index/field_index/facet_index.rs +++ b/lib/segment/src/index/field_index/facet_index.rs @@ -121,16 +121,9 @@ pub enum FacetIndexEnum<'a, S: UniversalReadExt = MmapFile> { Int(&'a MapIndex), Uuid(&'a MapIndex), Bool(&'a BoolIndex), - // Constructed only by `ReadOnlyFieldIndex::as_facet_index`, which is - // itself dead-code-allowed (`ReadOnlyFieldIndex` isn't wired into the - // read path yet). - #[allow(dead_code)] KeywordReadOnly(&'a ReadOnlyMapIndex), - #[allow(dead_code)] IntReadOnly(&'a ReadOnlyMapIndex), - #[allow(dead_code)] UuidReadOnly(&'a ReadOnlyMapIndex), - #[allow(dead_code)] BoolReadOnly(&'a ReadOnlyBoolIndex), } diff --git a/lib/segment/src/index/field_index/field_index_base/read_only/mod.rs b/lib/segment/src/index/field_index/field_index_base/read_only/mod.rs index 4d6e86c95e..29a392d7c7 100644 --- a/lib/segment/src/index/field_index/field_index_base/read_only/mod.rs +++ b/lib/segment/src/index/field_index/field_index_base/read_only/mod.rs @@ -26,10 +26,6 @@ use crate::types::{ DateTimePayloadType, FloatPayloadType, IntPayloadType, UuidIntType, UuidPayloadType, }; -// `lifecycle::open_gridstore` / `open_mmap` construct every variant, but they -// have no in-lib caller yet, so the variants would trip `dead_code`. Allow at -// the enum level until a read-only segment wires the opens in. -#[allow(dead_code, clippy::enum_variant_names)] pub enum ReadOnlyFieldIndex { IntIndex(ReadOnlyNumericIndex), DatetimeIndex(ReadOnlyNumericIndex), @@ -88,7 +84,6 @@ impl Debug for ReadOnlyFieldIndex { /// than degrading silently. /// /// [1]: crate::index::field_index::FieldIndex -#[allow(dead_code)] // skeleton: no caller in the lib yet; surface is here for follow-ups impl ReadOnlyFieldIndex { pub fn files(&self) -> Vec { match self { diff --git a/lib/segment/src/index/field_index/full_text_index/mutable_text_index/read_only/mod.rs b/lib/segment/src/index/field_index/full_text_index/mutable_text_index/read_only/mod.rs index a678c28a10..7c0bcf0f0d 100644 --- a/lib/segment/src/index/field_index/full_text_index/mutable_text_index/read_only/mod.rs +++ b/lib/segment/src/index/field_index/full_text_index/mutable_text_index/read_only/mod.rs @@ -25,6 +25,5 @@ pub struct ReadOnlyAppendableFullTextIndex { /// reads it lands with the parent dispatcher (it isn't part of the /// [`FullTextIndexRead`](super::super::full_text_index_read::FullTextIndexRead) /// surface). - #[allow(dead_code)] pub(super) storage: BlobstoreReader, S>, } diff --git a/lib/segment/src/index/field_index/geo_hash.rs b/lib/segment/src/index/field_index/geo_hash.rs index 8516086637..2d326c3127 100644 --- a/lib/segment/src/index/field_index/geo_hash.rs +++ b/lib/segment/src/index/field_index/geo_hash.rs @@ -288,7 +288,7 @@ pub fn geo_hash_to_box(geo_hash: GeoHash) -> GeoBoundingBox { struct GeohashBoundingBox { north_west: GeoHash, south_west: GeoHash, - #[allow(dead_code)] + #[cfg_attr(not(test), expect(dead_code))] south_east: GeoHash, // field is not involved in the calculations, but is kept for symmetry north_east: GeoHash, } diff --git a/lib/segment/src/index/field_index/map_index/mutable_map_index/read_only/mod.rs b/lib/segment/src/index/field_index/map_index/mutable_map_index/read_only/mod.rs index ad3ea26236..033b932490 100644 --- a/lib/segment/src/index/field_index/map_index/mutable_map_index/read_only/mod.rs +++ b/lib/segment/src/index/field_index/map_index/mutable_map_index/read_only/mod.rs @@ -28,6 +28,5 @@ where /// storage mapped; the `files` / `populate` / `clear_cache` wiring that /// reads it lands with the parent dispatcher (it isn't part of the /// [`MapIndexRead`](super::super::read_ops::MapIndexRead) surface). - #[allow(dead_code)] pub(super) storage: BlobstoreReader::Owned>, S>, } diff --git a/lib/segment/src/index/field_index/numeric_index/mutable_numeric_index/read_only/mod.rs b/lib/segment/src/index/field_index/numeric_index/mutable_numeric_index/read_only/mod.rs index 50cc154be2..bb03f5cd57 100644 --- a/lib/segment/src/index/field_index/numeric_index/mutable_numeric_index/read_only/mod.rs +++ b/lib/segment/src/index/field_index/numeric_index/mutable_numeric_index/read_only/mod.rs @@ -28,7 +28,6 @@ where /// storage mapped; the `files` / `populate` / `clear_cache` wiring that /// reads it lands with the storage-variant enum lifecycle (it isn't part of /// the [`NumericIndexRead`](super::super::numeric_index_read::NumericIndexRead) surface). - #[allow(dead_code)] pub(super) storage: BlobstoreReader, S>, } diff --git a/lib/segment/src/index/hnsw_index/hnsw.rs b/lib/segment/src/index/hnsw_index/hnsw.rs index fb4bef41db..2cec440e0d 100644 --- a/lib/segment/src/index/hnsw_index/hnsw.rs +++ b/lib/segment/src/index/hnsw_index/hnsw.rs @@ -20,7 +20,6 @@ mod build; #[cfg(feature = "gpu")] mod gpu_build; mod old_index; -#[allow(dead_code)] pub mod read_only; mod read_view; mod telemetry; diff --git a/lib/segment/src/segment/mod.rs b/lib/segment/src/segment/mod.rs index f41d20a667..f2d227ab6a 100644 --- a/lib/segment/src/segment/mod.rs +++ b/lib/segment/src/segment/mod.rs @@ -13,7 +13,6 @@ mod read_view; #[cfg(test)] mod tests; -#[allow(dead_code)] pub mod read_only; use std::collections::HashMap; diff --git a/lib/segment/src/types.rs b/lib/segment/src/types.rs index 484cb2db21..6c8cef0a63 100644 --- a/lib/segment/src/types.rs +++ b/lib/segment/src/types.rs @@ -3996,7 +3996,7 @@ pub enum Condition { #[serde( expecting = "Expected some form of condition, which can be a field condition (like {\"key\": ..., \"match\": ... }), or some other mentioned in the documentation: https://qdrant.tech/documentation/concepts/filtering/#filtering-conditions" )] -#[allow(clippy::large_enum_variant, dead_code)] +#[expect(clippy::large_enum_variant, dead_code)] enum ConditionUntagged { Field(FieldCondition), IsEmpty(IsEmptyCondition), diff --git a/lib/segment/src/vector_storage/dense/immutable_dense_vectors.rs b/lib/segment/src/vector_storage/dense/immutable_dense_vectors.rs index ecd09dc346..93fd2722fc 100644 --- a/lib/segment/src/vector_storage/dense/immutable_dense_vectors.rs +++ b/lib/segment/src/vector_storage/dense/immutable_dense_vectors.rs @@ -176,7 +176,7 @@ impl ImmutableDenseVectorData Ok(()) } - #[cfg_attr(not(target_os = "linux"), allow(dead_code))] + #[cfg_attr(not(target_os = "linux"), expect(dead_code))] fn for_each_in_batch_async( &self, keys: &[PointOffsetType], diff --git a/lib/segment/src/vector_storage/dense/read_only/lifecycle.rs b/lib/segment/src/vector_storage/dense/read_only/lifecycle.rs index ec58d22934..41ab13a56d 100644 --- a/lib/segment/src/vector_storage/dense/read_only/lifecycle.rs +++ b/lib/segment/src/vector_storage/dense/read_only/lifecycle.rs @@ -36,7 +36,6 @@ impl ReadOnlyChunkedDenseVectorStor /// Open the read-only counterpart of the appendable dense storage at `path`, /// threading every file open through `fs`; reads the existing layout but /// creates and writes nothing. `populate` warms the vector chunks. - #[allow(dead_code)] // pending: read-only vector storage enum will use this pub fn open( fs: &impl UniversalReadFs, path: &Path, diff --git a/lib/segment/src/vector_storage/multi_dense/read_only/lifecycle.rs b/lib/segment/src/vector_storage/multi_dense/read_only/lifecycle.rs index a4dd773c43..c9e289ea05 100644 --- a/lib/segment/src/vector_storage/multi_dense/read_only/lifecycle.rs +++ b/lib/segment/src/vector_storage/multi_dense/read_only/lifecycle.rs @@ -45,7 +45,6 @@ impl ReadOnlyChunkedMultiDenseVecto /// `path`, threading every file open through `fs`; reads the existing layout /// but creates and writes nothing. `populate` warms the vector and offset /// chunks. - #[allow(dead_code)] // pending: read-only vector storage enum will use this pub fn open( fs: &impl UniversalReadFs, path: &Path, diff --git a/lib/shard/src/segment_holder/locked.rs b/lib/shard/src/segment_holder/locked.rs index 613b83fa21..c880765643 100644 --- a/lib/shard/src/segment_holder/locked.rs +++ b/lib/shard/src/segment_holder/locked.rs @@ -12,7 +12,7 @@ use crate::segment_holder::SegmentHolder; /// This is used during critical sections like segment optimization finalization and snapshot /// operations to ensure consistency. #[must_use = "dropping this guard immediately releases the updates lock"] -#[allow(dead_code)] // Field is held for its RAII Drop behavior, not for reading +#[expect(dead_code)] // Field is held for its RAII Drop behavior, not for reading pub struct UpdatesGuard<'a>(parking_lot::MutexGuard<'a, ()>); #[derive(Clone, Debug)] diff --git a/lib/sparse/Cargo.toml b/lib/sparse/Cargo.toml index e14da70bdc..fdccd1b452 100644 --- a/lib/sparse/Cargo.toml +++ b/lib/sparse/Cargo.toml @@ -40,7 +40,6 @@ criterion = { workspace = true } dataset = { path = "../common/dataset" } duplicate = "2.0.1" fs-err = { workspace = true, features = ["debug"] } -generic-tests = { workspace = true } indicatif = { workspace = true } sha2 = { workspace = true } sparse = { path = ".", features = ["testing"] } diff --git a/lib/trififo/Cargo.toml b/lib/trififo/Cargo.toml index c06cbc63b8..76a5a6a471 100644 --- a/lib/trififo/Cargo.toml +++ b/lib/trififo/Cargo.toml @@ -30,9 +30,6 @@ foyer = "0.22" # For memory measurement cap = "0.1" -# For async runtime (needed by foyer) -tokio = { workspace = true } - [[bench]] name = "cache_comparison" harness = false diff --git a/lib/trififo/src/seqlock.rs b/lib/trififo/src/seqlock.rs index 330bb4f0e6..a813b19431 100644 --- a/lib/trififo/src/seqlock.rs +++ b/lib/trififo/src/seqlock.rs @@ -282,7 +282,7 @@ mod tests { ); } - #[allow(dead_code)] // body is compile-time `assert_impl_all!` checks, function is never called + #[expect(dead_code)] // body is compile-time `assert_impl_all!` checks, function is never called fn assert_correct_send_sync() { use std::rc::Rc; use std::sync::Mutex; diff --git a/lib/wal/src/lib.rs b/lib/wal/src/lib.rs index 8ceb25674e..b2b4b69ca4 100644 --- a/lib/wal/src/lib.rs +++ b/lib/wal/src/lib.rs @@ -1,5 +1,4 @@ use std::cmp::Ordering; -use std::collections::HashMap; use std::io::{Error, ErrorKind, Result}; use std::num::NonZeroUsize; use std::path::{Path, PathBuf}; @@ -84,7 +83,7 @@ pub struct Wal { /// The directory which contains the write ahead log. Used to hold an open /// file lock for the lifetime of the log. - #[allow(dead_code)] + #[expect(dead_code)] dir: File, /// The directory path. @@ -502,51 +501,6 @@ impl Wal { self.truncate(self.first_index()) } - /// Copy all files to the given path directory. directory should exist and be empty - pub fn copy_to_path

(&self, path: P) -> Result<()> - where - P: AsRef, - { - if fs::read_dir(path.as_ref())?.next().is_some() { - return Err(Error::new( - ErrorKind::AlreadyExists, - format!("path {:?} not empty", path.as_ref()), - )); - }; - - let open_segment_file = self.open_segment.segment.path().file_name().unwrap(); - let close_segment_files: HashMap<_, _> = self - .closed_segments - .iter() - .map(|segment| { - ( - segment.segment.path().file_name().unwrap(), - &segment.segment, - ) - }) - .collect(); - - for entry in fs::read_dir(self.path())? { - let entry = entry?; - if !entry.metadata()?.is_file() { - continue; - } - - // if file is locked by any Segment, call copy_to_path on it - let entry_file_name = entry.file_name(); - let dst_path = path.as_ref().to_owned().join(entry_file_name.clone()); - if entry_file_name == open_segment_file { - self.open_segment.segment.copy_to_path(&dst_path)?; - } else if let Some(segment) = close_segment_files.get(entry_file_name.as_os_str()) { - segment.copy_to_path(&dst_path)?; - } else { - // if file is not locked by any Segment, just copy it - fs::copy(entry.path(), &dst_path)?; - } - } - Ok(()) - } - /// Set how many segments closed segments to retain on prefix truncation. /// /// Can't be less than 1. If 0 is provided, it will be set to 1. diff --git a/lib/wal/src/mmap_view_sync.rs b/lib/wal/src/mmap_view_sync.rs index 471af766b1..5a4c9889fc 100644 --- a/lib/wal/src/mmap_view_sync.rs +++ b/lib/wal/src/mmap_view_sync.rs @@ -41,7 +41,7 @@ impl MmapViewSync { Ok(mmap.into()) } - #[allow(dead_code)] + #[cfg_attr(not(test), expect(dead_code))] pub fn anonymous(capacity: usize) -> Result { let mmap = MmapOptions::new().len(capacity).map_anon()?; @@ -51,7 +51,7 @@ impl MmapViewSync { /// Split the view into disjoint pieces at the specified offset. /// /// The provided offset must be less than the view's length. - #[allow(dead_code)] + #[cfg_attr(not(test), expect(dead_code))] pub fn split_at(self, offset: usize) -> Result<(MmapViewSync, MmapViewSync)> { if self.len < offset { return Err(Error::new( diff --git a/lib/wal/src/segment.rs b/lib/wal/src/segment.rs index d81c2b959f..596b6fa5d9 100644 --- a/lib/wal/src/segment.rs +++ b/lib/wal/src/segment.rs @@ -653,28 +653,6 @@ impl Segment { } } } - - pub(crate) fn copy_to_path

(&self, path: P) -> Result<()> - where - P: AsRef, - { - if path.as_ref().exists() { - return Err(Error::new( - ErrorKind::AlreadyExists, - format!("Path {:?} already exists", path.as_ref()), - )); - } - - let mut other = Self::create(path, self.capacity())?; - unsafe { - other - .mmap - .as_mut_slice() - .copy_from_slice(self.mmap.as_slice()); - } - other.mmap.flush()?; - Ok(()) - } } impl fmt::Debug for Segment { @@ -820,34 +798,6 @@ mod test { check_append(&mut create_segment(8 * 1024 * 1024).0); } - #[test] - fn test_copy_to_path_roundtrip() { - init_logger(); - let (mut segment, _dir) = create_segment(4096); - - let entries: Vec<&[u8]> = vec![ - b"alpha".as_slice(), - b"beta".as_slice(), - b"gamma".as_slice(), - b"delta".as_slice(), - ]; - for entry in &entries { - segment.append(entry).unwrap(); - } - segment.flush().unwrap(); - - let dst_dir = Builder::new().prefix("segment-copy").tempdir().unwrap(); - let dst_path = dst_dir.path().join("copied-segment"); - segment.copy_to_path(&dst_path).unwrap(); - - // The copy must be a complete, re-openable segment with byte-identical entries. - let copied = Segment::open(&dst_path).unwrap(); - assert_eq!(copied.len(), entries.len()); - for (idx, entry) in entries.iter().enumerate() { - assert_eq!(&*copied.entry(idx).unwrap(), *entry); - } - } - #[test] fn test_truncate() { init_logger(); diff --git a/src/common/debugger.rs b/src/common/debugger.rs index 74d155336c..5184dc00bc 100644 --- a/src/common/debugger.rs +++ b/src/common/debugger.rs @@ -28,7 +28,7 @@ pub enum DebugConfigPatch { } pub struct DebuggerState { - #[cfg_attr(not(target_os = "linux"), allow(dead_code))] + #[cfg_attr(not(target_os = "linux"), expect(dead_code))] pub pyroscope: Arc>>, } diff --git a/src/common/inference/api_keys.rs b/src/common/inference/api_keys.rs index 46035fc23e..a8fefe2d81 100644 --- a/src/common/inference/api_keys.rs +++ b/src/common/inference/api_keys.rs @@ -25,11 +25,6 @@ impl InferenceApiKeys { } } - /// Get the token as a string slice - pub fn token_as_str(&self) -> Option<&str> { - self.token.as_deref() - } - /// Single source of truth: extracts API keys from any iterator of (key, value) string pairs fn extract_keys_from_pairs<'a>(&mut self, iter: impl Iterator) { for (k, v) in iter { diff --git a/src/common/inference/mod.rs b/src/common/inference/mod.rs index 5d0d5b0291..9b7d361b72 100644 --- a/src/common/inference/mod.rs +++ b/src/common/inference/mod.rs @@ -1,4 +1,4 @@ -#![allow(dead_code)] +#![expect(dead_code)] pub mod api_keys; mod batch_processing; diff --git a/src/common/inference/params.rs b/src/common/inference/params.rs index f7508c8c98..c28a574676 100644 --- a/src/common/inference/params.rs +++ b/src/common/inference/params.rs @@ -10,9 +10,4 @@ impl InferenceParams { pub fn new(api_keys: InferenceApiKeys, timeout: Option) -> Self { Self { api_keys, timeout } } - - /// Get the inference token as a string slice - pub fn token_as_str(&self) -> Option<&str> { - self.api_keys.token_as_str() - } } diff --git a/src/common/stacktrace.rs b/src/common/stacktrace.rs index 036b339ce7..fb67f35de9 100644 --- a/src/common/stacktrace.rs +++ b/src/common/stacktrace.rs @@ -14,7 +14,10 @@ struct StackTraceFrame { } impl StackTraceFrame { - #[allow(dead_code)] + #[cfg_attr( + not(all(target_os = "linux", feature = "stacktrace")), + expect(dead_code) + )] pub fn render(&self) -> String { let mut result = String::new(); for symbol in &self.symbols { diff --git a/src/schema_generator.rs b/src/schema_generator.rs index 67fced89ae..1993f1afed 100644 --- a/src/schema_generator.rs +++ b/src/schema_generator.rs @@ -1,4 +1,4 @@ -#![allow(dead_code)] +#![expect(dead_code)] use api::rest::models::{CollectionsResponse, ShardKeysResponse, Usage, VersionInfo}; use api::rest::schema::PointInsertOperations; diff --git a/tools/ast-grep/rules/no-allow-dead-code.yml b/tools/ast-grep/rules/no-allow-dead-code.yml new file mode 100644 index 0000000000..9e62fd506c --- /dev/null +++ b/tools/ast-grep/rules/no-allow-dead-code.yml @@ -0,0 +1,21 @@ +id: no-allow-dead-code +language: rust +severity: error +message: "`allow(dead_code)` instead of `expect(dead_code)`" +ignores: + - lib/api/src/grpc/** + - lib/edge/publish/** + - lib/uio-grpc-client/src/generated/** +rule: + any: + - kind: attribute_item + - kind: inner_attribute_item + has: + stopBy: end + kind: token_tree + has: + kind: identifier + regex: ^dead_code$ + follows: + kind: identifier + regex: ^allow$ diff --git a/tools/ast-grep/sgconfig.yml b/tools/ast-grep/sgconfig.yml index 098ecb2af4..99e337dfdf 100644 --- a/tools/ast-grep/sgconfig.yml +++ b/tools/ast-grep/sgconfig.yml @@ -1,4 +1,4 @@ ruleDirs: - rules testConfigs: - - testDir: rule-tests + - testDir: tests diff --git a/tools/ast-grep/tests/no-allow-dead-code.yml b/tools/ast-grep/tests/no-allow-dead-code.yml new file mode 100644 index 0000000000..05e4d80739 --- /dev/null +++ b/tools/ast-grep/tests/no-allow-dead-code.yml @@ -0,0 +1,42 @@ +id: no-allow-dead-code +valid: + # The replacement this rule pushes towards. + - | + #[expect(dead_code)] + fn f() {} + # Narrowed to the configuration in which the item is actually dead. + - | + #[cfg_attr(not(test), expect(dead_code))] + fn f() {} + # Other lints may still be silenced with `allow`. + - | + #[allow(clippy::enum_variant_names)] + fn f() {} + # `dead_code` appearing outside an `allow` list is not a suppression. + - | + fn dead_code() {} +invalid: + - | + #[allow(dead_code)] + fn f() {} + # Inner attribute, silencing a whole module. + - | + #![allow(dead_code)] + fn f() {} + # Alongside other lints, in either position. + - | + #[allow(dead_code, clippy::enum_variant_names)] + enum E { + AFoo, + BFoo, + } + - | + #[allow(unused_imports, dead_code)] + fn f() {} + # Nested in `cfg_attr`, where it is not an `attribute` node. + - | + #[cfg_attr(not(test), allow(dead_code))] + fn f() {} + - | + #[cfg_attr(not(target_os = "linux"), allow(dead_code))] + fn f() {} diff --git a/tools/ast-grep/rule-tests/no-default-batch-methods-test.yml b/tools/ast-grep/tests/no-default-batch-methods.yml similarity index 100% rename from tools/ast-grep/rule-tests/no-default-batch-methods-test.yml rename to tools/ast-grep/tests/no-default-batch-methods.yml