mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 05:33:27 +00:00
parent
334be18a74
commit
ffc75af4cd
3 changed files with 16 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use clippy_utils::{expr_custom_deref_adjustment, ty::is_type_diagnostic_item};
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Expr, Mutability};
|
||||
|
@ -11,6 +11,7 @@ use super::MUT_MUTEX_LOCK;
|
|||
|
||||
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, ex: &'tcx Expr<'tcx>, recv: &'tcx Expr<'tcx>, name_span: Span) {
|
||||
if_chain! {
|
||||
if matches!(expr_custom_deref_adjustment(cx, recv), None | Some(Mutability::Mut));
|
||||
if let ty::Ref(_, _, Mutability::Mut) = cx.typeck_results().expr_ty(recv).kind();
|
||||
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(ex.hir_id);
|
||||
if let Some(impl_id) = cx.tcx.impl_of_method(method_id);
|
||||
|
|
|
@ -18,4 +18,11 @@ fn no_owned_mutex_lock() {
|
|||
*value += 1;
|
||||
}
|
||||
|
||||
fn issue9415() {
|
||||
let mut arc_mutex = Arc::new(Mutex::new(42_u8));
|
||||
let arc_mutex: &mut Arc<Mutex<u8>> = &mut arc_mutex;
|
||||
let mut guard = arc_mutex.lock().unwrap();
|
||||
*guard += 1;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -18,4 +18,11 @@ fn no_owned_mutex_lock() {
|
|||
*value += 1;
|
||||
}
|
||||
|
||||
fn issue9415() {
|
||||
let mut arc_mutex = Arc::new(Mutex::new(42_u8));
|
||||
let arc_mutex: &mut Arc<Mutex<u8>> = &mut arc_mutex;
|
||||
let mut guard = arc_mutex.lock().unwrap();
|
||||
*guard += 1;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
Loading…
Reference in a new issue