Skip to content

Conversation

@Tunglies
Copy link

@Tunglies Tunglies commented Dec 2, 2025

changelog: [rwlock_atomic]: new lint
changelog: [rwlock_integer]: new lint

changelog: [`rwlock_atomic`]: new lint
changelog: [`rwlock_integer`]: new lint
@rustbot rustbot added needs-fcp S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Dec 2, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 2, 2025

r? @blyxyas

rustbot has assigned @blyxyas.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@Tunglies
Copy link
Author

Tunglies commented Dec 2, 2025

Hey @blyxyas, would you be interested in reviewing?

@blyxyas
Copy link
Member

blyxyas commented Dec 2, 2025

Yes @Tunglies I'll review this one, could you give us some more information in the pull request's description? Is this fixing any existing issues? In general, more context on why this pull request is needed would be very appreciated.

Thanks!

@Tunglies
Copy link
Author

Tunglies commented Dec 2, 2025

Yes @Tunglies I'll review this one, could you give us some more information in the pull request's description? Is this fixing any existing issues? In general, more context on why this pull request is needed would be very appreciated.

Thanks!

I found Mutex rulesclippy::mutex_atomic and clippy::mutex_integer rules, use them for my comunnity's project clash-verge-rev to helps reduce Arc and lock performance cost, most are Arc<Mutex/Rwlock<bool>>. I tried write some basic branchmark for Arc<Mutex/RwLock<T>> and Atomic<T> with std lib, found that Arc<RwLock<T>> is even slower than Arc<Mutex<T>>. While continue performance development, if has Rwlock rule for this usage same as clippy::mutex_atomic and clippy::mutex_integer would be more convenience.

Copy link
Member

@blyxyas blyxyas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that the lint logic is really similar to mutex_atomic, could you merge these?

View changes since this review

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Dec 4, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 4, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

gauravagerwala added a commit to gauravagerwala/rust-clippy that referenced this pull request Dec 7, 2025
@Tunglies Tunglies marked this pull request as draft December 9, 2025 00:06
…ld be used instead

- Added new lints: `RWLOCK_ATOMIC`, `RWLOCK_INTEGER`, `MUTEX_ATOMIC`, and `MUTEX_INTEGER` to check for inappropriate usage of `RwLock` and `Mutex` with atomic types.
- Created a new lint pass `SyncGuard` to handle the linting logic for these cases.
- Updated tests to cover various scenarios where `RwLock` and `Mutex` are used with atomic types, ensuring that the lints trigger correctly.
- Removed outdated test files and added new tests to validate the behavior of the new lints.
- Rename rwlock_atomic.rs to rwlock_mutex_atomic.rs
@Tunglies
Copy link
Author

Tunglies commented Dec 9, 2025

Hey @blyxyas I have merged the lints and renamed the lint file and its uibless counterpart. Looking forward to your feedback :3

@Tunglies Tunglies marked this pull request as ready for review December 9, 2025 01:37
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 9, 2025
@Tunglies
Copy link
Author

Tunglies commented Dec 9, 2025

@rustbot ready

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-fcp S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants