about summary refs log tree commit diff
path: root/compiler/rustc_lint/src/noop_method_call.rs
diff options
context:
space:
mode:
authorDeadbeef <ent3rm4n@gmail.com>2023-05-25 05:21:44 +0000
committerDeadbeef <ent3rm4n@gmail.com>2023-07-23 09:58:31 +0000
commit626efab67f184658eb966d3a69c31d7f1deb47e4 (patch)
tree4d704671fa975f0279c5fd45e258879209129d3c /compiler/rustc_lint/src/noop_method_call.rs
parent33ec4e4bb0e332072b5dbd31f8f024dff4e3f44e (diff)
downloadrust-626efab67f184658eb966d3a69c31d7f1deb47e4.tar.gz
rust-626efab67f184658eb966d3a69c31d7f1deb47e4.zip
fix
Diffstat (limited to 'compiler/rustc_lint/src/noop_method_call.rs')
-rw-r--r--compiler/rustc_lint/src/noop_method_call.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/rustc_lint/src/noop_method_call.rs b/compiler/rustc_lint/src/noop_method_call.rs
index 2817a665bb0..bc0b9d6d818 100644
--- a/compiler/rustc_lint/src/noop_method_call.rs
+++ b/compiler/rustc_lint/src/noop_method_call.rs
@@ -85,10 +85,9 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
 
         let Some(trait_id) = cx.tcx.trait_of_item(did) else { return };
 
-        if !matches!(
-            cx.tcx.get_diagnostic_name(trait_id),
-            Some(sym::Borrow | sym::Clone | sym::Deref)
-        ) {
+        let Some(trait_) = cx.tcx.get_diagnostic_name(trait_id) else { return };
+
+        if !matches!(trait_, sym::Borrow | sym::Clone | sym::Deref) {
             return;
         };
 
@@ -113,11 +112,13 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
         let expr_span = expr.span;
         let span = expr_span.with_lo(receiver.span.hi());
 
+        let orig_ty = expr_ty.peel_refs();
+
         if receiver_ty == expr_ty {
             cx.emit_spanned_lint(
                 NOOP_METHOD_CALL,
                 span,
-                NoopMethodCallDiag { method: call.ident.name, receiver_ty, label: span },
+                NoopMethodCallDiag { method: call.ident.name, orig_ty, trait_, label: span },
             );
         } else {
             match name {