rust-lang / rust-lang/rust-clippy
Warn about `Mutex<()>`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
I can't think of a use case where this actually gives you any guarantees. You can still use it to protect another Sync data structure, but you can just as well forget to do so. One should always put the components that are protected into the Mutex even if not strictly necessary due to the componentes being thread safe themselves.
An example of such a situation would be
struct Foo {
lock: Mutex<()>,
a: AtomicUsize,
b: AtomicUsize,
}
where one should not modify the two values one by one, but always together in a single critical section.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Use the issue body and its Mutex<()> example as the starting specification. First determine the intended warning scope and how it should handle protected Sync data structures and paired AtomicUsize values; done means the warning behavior and its false-positive boundaries are defined and verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100