From d9993cb133909eb17705cd9dc518c2c213fc779b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sosth=C3=A8ne=20Gu=C3=A9don?= <sosthene@guedon.gdn>
Date: Sun, 20 Nov 2022 12:20:16 +0100
Subject: [PATCH] Remove error when fields use autoderef

---
 clippy_lints/src/functions/misnamed_getters.rs | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/clippy_lints/src/functions/misnamed_getters.rs b/clippy_lints/src/functions/misnamed_getters.rs
index 599269e2d63..c553901059b 100644
--- a/clippy_lints/src/functions/misnamed_getters.rs
+++ b/clippy_lints/src/functions/misnamed_getters.rs
@@ -101,16 +101,14 @@ pub fn check_fn(
     }
 
     let Some(used_field) = used_field else {
-            if cfg!(debug_assertions) {
-                panic!("Struct doesn't contain the correct field");
-            } else {
-                // Don't ICE when possible
-                return;
-            }
-        };
+        // FIXME: This can be reached if the field access uses autoderef.
+        // `dec.all_fields()` should be replaced by something that uses autoderef.
+        return;
+    };
+
     let Some(correct_field) = correct_field else {
             return;
-        };
+    };
 
     if cx.tcx.type_of(used_field.did) == cx.tcx.type_of(correct_field.did) {
         let left_span = block_expr.span.until(used_ident.span);