about summary refs log tree commit diff
diff options
context:
space:
mode:
authory21 <30553356+y21@users.noreply.github.com>2023-07-03 01:12:08 +0200
committery21 <30553356+y21@users.noreply.github.com>2023-08-14 16:28:04 +0200
commit34348f72f40b070a1a5fe5eac829e41cbd5f98e1 (patch)
tree362b4ef3a4c86b5e7f0e8ef8ce4008529b1d91d1
parentb5bfd1176b3d0de03e63c8d0b244ef61b30067d8 (diff)
downloadrust-34348f72f40b070a1a5fe5eac829e41cbd5f98e1.tar.gz
rust-34348f72f40b070a1a5fe5eac829e41cbd5f98e1.zip
[`useless_conversion`]: make sure path points to fn-like item
-rw-r--r--clippy_lints/src/useless_conversion.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/clippy_lints/src/useless_conversion.rs b/clippy_lints/src/useless_conversion.rs
index 92b694d3076..3be4fb7cc32 100644
--- a/clippy_lints/src/useless_conversion.rs
+++ b/clippy_lints/src/useless_conversion.rs
@@ -150,9 +150,14 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
                 {
                     if let Some(parent) = get_parent_expr(cx, e) {
                         let parent_fn = match parent.kind {
-                            ExprKind::Call(recv, args) if let ExprKind::Path(ref qpath) = recv.kind => {
-                                cx.qpath_res(qpath, recv.hir_id).opt_def_id()
-                                    .map(|did| (did, args, MethodOrFunction::Function))
+                            ExprKind::Call(recv, args)
+                                if let ExprKind::Path(ref qpath) = recv.kind
+                                    && let Some(did) = cx.qpath_res(qpath, recv.hir_id).opt_def_id()
+                                    // make sure that the path indeed points to a fn-like item, so that
+                                    // `fn_sig` does not ICE. (see #11065)
+                                    && cx.tcx.opt_def_kind(did).is_some_and(|k| k.is_fn_like()) =>
+                            {
+                                    Some((did, args, MethodOrFunction::Function))
                             }
                             ExprKind::MethodCall(.., args, _) => {
                                 cx.typeck_results().type_dependent_def_id(parent.hir_id)