Skip to content

Move mutex_atomic to restriction #10115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions clippy_lints/src/mutex_atomic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Checks for uses of mutex where an atomic value could be used
//!
//! This lint is **warn** by default
//! This lint is **allow** by default

use clippy_utils::diagnostics::span_lint;
use clippy_utils::ty::is_type_diagnostic_item;
Expand All @@ -20,6 +20,10 @@ declare_clippy_lint! {
/// `std::sync::atomic::AtomicBool` and `std::sync::atomic::AtomicPtr` are leaner and
/// faster.
///
/// On the other hand, `Mutex`es are, in general, easier to
/// verify correctness. An atomic does not behave the same as
/// an equivalent mutex. See [this issue](https://github.com/rust-lang/rust-clippy/issues/4295)'s commentary for more details.
///
/// ### Known problems
/// This lint cannot detect if the mutex is actually used
/// for waiting before a critical section.
Expand All @@ -39,8 +43,8 @@ declare_clippy_lint! {
/// ```
#[clippy::version = "pre 1.29.0"]
pub MUTEX_ATOMIC,
nursery,
"using a mutex where an atomic value could be used instead"
restriction,
"using a mutex where an atomic value could be used instead."
}

declare_clippy_lint! {
Expand Down