fn expr_require_exclusive_access(ctx: &AssistContext, expr: &ast::Expr) -> Option<bool> {
    let parent = expr.syntax().parent()?;

    if let Some(bin_expr) = ast::BinExpr::cast(parent.clone()) {
        if bin_expr.op_kind()?.is_assignment() {
            return Some(bin_expr.lhs()?.syntax() == expr.syntax());
        }
        return Some(false);
    }

    if let Some(ref_expr) = ast::RefExpr::cast(parent.clone()) {
        return Some(ref_expr.mut_token().is_some());
    }

    if let Some(method_call) = ast::MethodCallExpr::cast(parent.clone()) {
        let func = ctx.sema.resolve_method_call(&method_call)?;
        let self_param = func.self_param(ctx.db())?;
        let access = self_param.access(ctx.db());

        return Some(matches!(access, hir::Access::Exclusive));
    }

    if let Some(field) = ast::FieldExpr::cast(parent) {
        return expr_require_exclusive_access(ctx, &field.into());
    }

    Some(false)
}
/// checks if this expr requires `&mut` access, recurses on field access
checks if this expr requires `&mut` access, recurses on field access
checks if this expr requires ` &mut ` access recurses on field access
fn expr_require_exclusive_access(ctx: &AssistContext, expr: &ast::Expr) -> Option<bool> {
    let parent = expr.syntax().parent()?;
    if let Some(bin_expr) = ast::BinExpr::cast(parent.clone()) {
        if bin_expr.op_kind()?.is_assignment() {
            return Some(bin_expr.lhs()?.syntax() == expr.syntax());
        }
        return Some(false);
    }
    if let Some(ref_expr) = ast::RefExpr::cast(parent.clone()) {
        return Some(ref_expr.mut_token().is_some());
    }
    if let Some(method_call) = ast::MethodCallExpr::cast(parent.clone()) {
        let func = ctx.sema.resolve_method_call(&method_call)?;
        let self_param = func.self_param(ctx.db())?;
        let access = self_param.access(ctx.db());
        return Some(matches!(access, hir::Access::Exclusive));
    }
    if let Some(field) = ast::FieldExpr::cast(parent) {
        return expr_require_exclusive_access(ctx, &field.into());
    }
    Some(false)
}
fn expr_require_exclusive_access ( ctx : & AssistContext , expr : & ast :: Expr ) -> Option < bool > { let parent = expr . syntax ( ) . parent ( ) ? ; if let Some ( bin_expr ) = ast :: BinExpr :: cast ( parent . clone ( ) ) { if bin_expr . op_kind ( ) ? . is_assignment ( ) { return Some ( bin_expr . lhs ( ) ? . syntax ( ) == expr . syntax ( ) ) ; } return Some ( false ) ; } if let Some ( ref_expr ) = ast :: RefExpr :: cast ( parent . clone ( ) ) { return Some ( ref_expr . mut_token ( ) . is_some ( ) ) ; } if let Some ( method_call ) = ast :: MethodCallExpr :: cast ( parent . clone ( ) ) { let func = ctx . sema . resolve_method_call ( & method_call ) ? ; let self_param = func . self_param ( ctx . db ( ) ) ? ; let access = self_param . access ( ctx . db ( ) ) ; return Some ( matches ! ( access hir Access Exclusive ) ) ; } if let Some ( field ) = ast :: FieldExpr :: cast ( parent ) { return expr_require_exclusive_access ( ctx , & field . into ( ) ) ; } Some ( false ) }
checks if this expr requires `&mut` access, recurses on field access
checks if this expr requires ` &mut ` access recurses on field access
ctx
&AssistContext
expr
&ast::Expr
ctx
&AssistContext
expr
&ast::Expr