use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty;
use rustc_session::{declare_lint_pass, declare_tool_lint};
+use rustc_span::sym;
declare_clippy_lint! {
/// ### What it does
impl<'tcx> LateLintPass<'tcx> for MutMutexLock {
fn check_expr(&mut self, cx: &LateContext<'tcx>, ex: &'tcx Expr<'tcx>) {
if_chain! {
- if let ExprKind::MethodCall(path, method_span, args, _) = &ex.kind;
+ if let ExprKind::MethodCall(path, method_span, [self_arg, ..], _) = &ex.kind;
if path.ident.name == sym!(lock);
- let ty = cx.typeck_results().expr_ty(&args[0]);
+ let ty = cx.typeck_results().expr_ty(self_arg);
if let ty::Ref(_, inner_ty, Mutability::Mut) = ty.kind();
- if is_type_diagnostic_item(cx, inner_ty, sym!(mutex_type));
+ if is_type_diagnostic_item(cx, inner_ty, sym::Mutex);
then {
span_lint_and_sugg(
cx,