Repository navigation
Add struct destructuring to catch missing fields at compile time - #8497
Conversation
Destructure structs in conversions, key/match functions, and config builders so the compiler will error when new fields are added but not handled. This prevents a common class of bugs where a newly added struct field is silently ignored. Covered spots: - RecommendPointGroups → RecommendGroupsRequestInternal (15 fields) - ShardTransferTelemetry ↔ ShardTransferInfo (7 fields, both directions) - ReshardingTelemetry ↔ ReshardingInfo (6 fields, both directions) - HwMeasurementAcc → HardwareUsage (7 fields, 3 call sites) - VectorParams destructuring in optimizers_builder and config (7 fields) - SparseVectorParams destructuring in optimizers_builder (2 fields) - ShardTransfer → ShardTransferRestart (5 fields) - ReshardState::matches and ReshardState::key (5 fields each) - ShardTransfer::key and ShardTransferRestart::key (4 fields each) - SnapshotDescription → grpc (4 fields) - WithLookup REST → internal (3 fields) - SegmentConfigV5 → SegmentConfig (5 fields) Made-with: Cursor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (11)
📝 WalkthroughWalkthroughThis PR refactors field access patterns across 11 files by systematically replacing direct field access (e.g., Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Destructure structs in conversions, key/match functions, and config builders so the compiler will error when new fields are added but not handled. This prevents a common class of bugs where a newly added struct field is silently ignored. Covered spots: - RecommendPointGroups → RecommendGroupsRequestInternal (15 fields) - ShardTransferTelemetry ↔ ShardTransferInfo (7 fields, both directions) - ReshardingTelemetry ↔ ReshardingInfo (6 fields, both directions) - HwMeasurementAcc → HardwareUsage (7 fields, 3 call sites) - VectorParams destructuring in optimizers_builder and config (7 fields) - SparseVectorParams destructuring in optimizers_builder (2 fields) - ShardTransfer → ShardTransferRestart (5 fields) - ReshardState::matches and ReshardState::key (5 fields each) - ShardTransfer::key and ShardTransferRestart::key (4 fields each) - SnapshotDescription → grpc (4 fields) - WithLookup REST → internal (3 fields) - SegmentConfigV5 → SegmentConfig (5 fields) Made-with: Cursor Co-authored-by: Cursor Agent <[email protected]>
Destructure structs in conversions, key/match functions, and config builders so the compiler will error when new fields are added but not handled. This prevents a common class of bugs where a newly added struct field is silently ignored. Covered spots: - RecommendPointGroups → RecommendGroupsRequestInternal (15 fields) - ShardTransferTelemetry ↔ ShardTransferInfo (7 fields, both directions) - ReshardingTelemetry ↔ ReshardingInfo (6 fields, both directions) - HwMeasurementAcc → HardwareUsage (7 fields, 3 call sites) - VectorParams destructuring in optimizers_builder and config (7 fields) - SparseVectorParams destructuring in optimizers_builder (2 fields) - ShardTransfer → ShardTransferRestart (5 fields) - ReshardState::matches and ReshardState::key (5 fields each) - ShardTransfer::key and ShardTransferRestart::key (4 fields each) - SnapshotDescription → grpc (4 fields) - WithLookup REST → internal (3 fields) - SegmentConfigV5 → SegmentConfig (5 fields) Made-with: Cursor Co-authored-by: Cursor Agent <[email protected]>
Summary
value.field). This ensures the compiler will produce an error when a new field is added to a struct but not handled in these conversion/construction sites.From/TryFromimpls, key extraction methods, and config builders.Covered spots
operations/conversions.rsRecommendPointGroups→RecommendGroupsRequestInternaltelemetry.rsgrpc::ShardTransferTelemetry→ShardTransferInfotelemetry.rsShardTransferInfo→grpc::ShardTransferTelemetrytelemetry.rsgrpc::ReshardingTelemetry→ReshardingInfotelemetry.rsReshardingInfo→grpc::ReshardingTelemetrygrpc/conversions.rsHwMeasurementAcc→HardwareUsage(viaHardwareDatadestructuring)request_hw_counter.rsto_rest_apiandto_grpc_api(viaHardwareDatadestructuring)optimizers_builder.rsVectorParams+SparseVectorParamsinbuild_segment_optimizer_configconfig.rsVectorParamsinto_base_vector_datatransfer/mod.rsShardTransfer::key,ShardTransferRestart::key,from_transferresharding.rsReshardState::matchesandReshardState::keysnapshot_ops.rs,lookup/types.rs,compat.rsSnapshotDescription,WithLookup,SegmentConfigV5conversionsTest plan
cargo checkpassescargo +nightly fmt --all -- --checkpassesMade with Cursor