Skip to content

Commit 34348f7

Browse files
committed
[useless_conversion]: make sure path points to fn-like item
1 parent b5bfd11 commit 34348f7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

clippy_lints/src/useless_conversion.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,14 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
150150
{
151151
if let Some(parent) = get_parent_expr(cx, e) {
152152
let parent_fn = match parent.kind {
153-
ExprKind::Call(recv, args) if let ExprKind::Path(ref qpath) = recv.kind => {
154-
cx.qpath_res(qpath, recv.hir_id).opt_def_id()
155-
.map(|did| (did, args, MethodOrFunction::Function))
153+
ExprKind::Call(recv, args)
154+
if let ExprKind::Path(ref qpath) = recv.kind
155+
&& let Some(did) = cx.qpath_res(qpath, recv.hir_id).opt_def_id()
156+
// make sure that the path indeed points to a fn-like item, so that
157+
// `fn_sig` does not ICE. (see #11065)
158+
&& cx.tcx.opt_def_kind(did).is_some_and(|k| k.is_fn_like()) =>
159+
{
160+
Some((did, args, MethodOrFunction::Function))
156161
}
157162
ExprKind::MethodCall(.., args, _) => {
158163
cx.typeck_results().type_dependent_def_id(parent.hir_id)

0 commit comments

Comments
 (0)