pub struct LockScopeMutation {
pub target_fn: Option<SymbolId>,
}Expand description
Detects locks held across await points or with unnecessarily wide scope.
This is a safety pattern that helps prevent deadlocks and improves concurrency by reducing lock hold times.
§Example
ⓘ
// Problematic: lock held across await
async fn bad() {
let guard = self.data.lock().unwrap();
some_async_operation().await; // Lock still held!
drop(guard);
}
// Better: release lock before await
async fn good() {
let value = {
let guard = self.data.lock().unwrap();
guard.clone()
}; // Lock released
some_async_operation().await;
}Fields§
§target_fn: Option<SymbolId>Target function SymbolId. If None, applies to all functions.
Implementations§
Trait Implementations§
Source§impl Clone for LockScopeMutation
impl Clone for LockScopeMutation
Source§fn clone(&self) -> LockScopeMutation
fn clone(&self) -> LockScopeMutation
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LockScopeMutation
impl Debug for LockScopeMutation
Source§impl Default for LockScopeMutation
impl Default for LockScopeMutation
Source§fn default() -> LockScopeMutation
fn default() -> LockScopeMutation
Returns the “default value” for a type. Read more
Source§impl Detect for LockScopeMutation
impl Detect for LockScopeMutation
Source§fn category(&self) -> DetectCategory
fn category(&self) -> DetectCategory
Get the category for detected opportunities
Source§fn detect_name(&self) -> &'static str
fn detect_name(&self) -> &'static str
Get the mutation/pattern name
Source§fn detect_description(&self) -> &str
fn detect_description(&self) -> &str
Get description
Source§impl Mutation for LockScopeMutation
impl Mutation for LockScopeMutation
Source§fn mutation_type(&self) -> &'static str
fn mutation_type(&self) -> &'static str
Get the mutation type name
Source§fn validate(&self, _file: &PureFile) -> ValidationResult
fn validate(&self, _file: &PureFile) -> ValidationResult
Validate the mutation before applying Read more
Source§fn can_proceed(&self, file: &PureFile, strategy: ValidationStrategy) -> bool
fn can_proceed(&self, file: &PureFile, strategy: ValidationStrategy) -> bool
Check if this mutation can proceed with the given strategy
Auto Trait Implementations§
impl Freeze for LockScopeMutation
impl RefUnwindSafe for LockScopeMutation
impl Send for LockScopeMutation
impl Sync for LockScopeMutation
impl Unpin for LockScopeMutation
impl UnsafeUnpin for LockScopeMutation
impl UnwindSafe for LockScopeMutation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more