Repository navigation
Add #[must_use] to RAII guard and task handle types - #8499
Conversation
These types rely on being held for a scope — dropping them immediately is almost always a bug: - `StoppingGuard`: sets `is_stopped` flag on drop - `UpdateGuard`: decrements update counter on drop - `UpdatesGuard`: releases mutex preventing concurrent updates on drop - `ClockGuard`: marks clock as inactive on drop - `IsAliveGuard`: releases liveness lock on drop - `ScopeTrackerGuard`: decrements scope counter on drop - `CancellableAsyncTaskHandle`: detaches task on drop - `StoppableTaskHandle`: may abort task on drop (AbortOnDropHandle) Made-with: Cursor
With ScopeTrackerGuard marked #[must_use] at the type level, the function-level attributes on measure_scope(), measure(), track_create_snapshot_request(), and count_snapshot_creation() are redundant and trigger clippy::double_must_use. 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 (10)
💤 Files with no reviewable changes (2)
📝 WalkthroughWalkthroughThis pull request systematically adds Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 |
* Add `#[must_use]` to RAII guard and task handle types These types rely on being held for a scope — dropping them immediately is almost always a bug: - `StoppingGuard`: sets `is_stopped` flag on drop - `UpdateGuard`: decrements update counter on drop - `UpdatesGuard`: releases mutex preventing concurrent updates on drop - `ClockGuard`: marks clock as inactive on drop - `IsAliveGuard`: releases liveness lock on drop - `ScopeTrackerGuard`: decrements scope counter on drop - `CancellableAsyncTaskHandle`: detaches task on drop - `StoppableTaskHandle`: may abort task on drop (AbortOnDropHandle) Made-with: Cursor * Remove redundant function-level #[must_use] now covered by type With ScopeTrackerGuard marked #[must_use] at the type level, the function-level attributes on measure_scope(), measure(), track_create_snapshot_request(), and count_snapshot_creation() are redundant and trigger clippy::double_must_use. Made-with: Cursor --------- Co-authored-by: Cursor Agent <[email protected]>
* Add `#[must_use]` to RAII guard and task handle types These types rely on being held for a scope — dropping them immediately is almost always a bug: - `StoppingGuard`: sets `is_stopped` flag on drop - `UpdateGuard`: decrements update counter on drop - `UpdatesGuard`: releases mutex preventing concurrent updates on drop - `ClockGuard`: marks clock as inactive on drop - `IsAliveGuard`: releases liveness lock on drop - `ScopeTrackerGuard`: decrements scope counter on drop - `CancellableAsyncTaskHandle`: detaches task on drop - `StoppableTaskHandle`: may abort task on drop (AbortOnDropHandle) Made-with: Cursor * Remove redundant function-level #[must_use] now covered by type With ScopeTrackerGuard marked #[must_use] at the type level, the function-level attributes on measure_scope(), measure(), track_create_snapshot_request(), and count_snapshot_creation() are redundant and trigger clippy::double_must_use. Made-with: Cursor --------- Co-authored-by: Cursor Agent <[email protected]>
Summary
#[must_use]with descriptive messages to 8 RAII guard and task handle types whose correctness depends on being held for a scopeStoppingGuard,UpdateGuard,UpdatesGuard,ClockGuard,IsAliveGuard,ScopeTrackerGuardCancellableAsyncTaskHandle,StoppableTaskHandleDropimplementations (or wrap types that do) where dropping immediately is a silent correctness bug — the compiler will now warn if a value of these types is unusedThe codebase already follows this pattern in a few places (e.g.
CountedProcessHandlehas#[must_use = "Dropping this handle will immediately decrease the process count"]), this PR extends it consistently to other types that fit the same criteria.Test plan
cargo checkpasses cleanly oncommon,collection, andshardcrates with no new warnings#[must_use]is a lint-only annotationMade with Cursor