From 66bc682caba7d7c2ea68764e885b337e7610362e Mon Sep 17 00:00:00 2001 From: Jason Newcomb Date: Wed, 27 Sep 2023 11:01:41 -0400 Subject: Fix `noop_method_call` detection for new diagnostic items --- compiler/rustc_lint/src/noop_method_call.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'compiler/rustc_lint/src') diff --git a/compiler/rustc_lint/src/noop_method_call.rs b/compiler/rustc_lint/src/noop_method_call.rs index bc0b9d6d818..cfbca6efbfa 100644 --- a/compiler/rustc_lint/src/noop_method_call.rs +++ b/compiler/rustc_lint/src/noop_method_call.rs @@ -98,6 +98,12 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall { let Ok(Some(i)) = ty::Instance::resolve(cx.tcx, cx.param_env, did, args) else { return }; // (Re)check that it implements the noop diagnostic. let Some(name) = cx.tcx.get_diagnostic_name(i.def_id()) else { return }; + if !matches!( + name, + sym::noop_method_borrow | sym::noop_method_clone | sym::noop_method_deref + ) { + return; + } let receiver_ty = cx.typeck_results().expr_ty(receiver); let expr_ty = cx.typeck_results().expr_ty_adjusted(expr); -- cgit 1.4.1-3-g733a5