Skip to content

Commit c01bec6

Browse files
committed
[useless_conversion]: make sure path points to fn-like item
1 parent 17a48c2 commit c01bec6

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
@@ -151,9 +151,14 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
151151
{
152152
if let Some(parent) = get_parent_expr(cx, e) {
153153
let parent_fn = match parent.kind {
154-
ExprKind::Call(recv, args) if let ExprKind::Path(ref qpath) = recv.kind => {
155-
cx.qpath_res(qpath, recv.hir_id).opt_def_id()
156-
.map(|did| (did, args, MethodOrFunction::Function))
154+
ExprKind::Call(recv, args)
155+
if let ExprKind::Path(ref qpath) = recv.kind
156+
&& let Some(did) = cx.qpath_res(qpath, recv.hir_id).opt_def_id()
157+
// make sure that the path indeed points to a fn-like item, so that
158+
// `fn_sig` does not ICE. (see #11065)
159+
&& cx.tcx.opt_def_kind(did).is_some_and(|k| k.is_fn_like()) =>
160+
{
161+
Some((did, args, MethodOrFunction::Function))
157162
}
158163
ExprKind::MethodCall(.., args, _) => {
159164
cx.typeck_results().type_dependent_def_id(parent.hir_id)

0 commit comments

Comments
 (0)