mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-02 10:04:23 +00:00
[useless_conversion
]: make sure path points to fn-like item
This commit is contained in:
parent
b5bfd1176b
commit
34348f72f4
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user