From bafa200f6edc454b423d847db88d867584c10e18 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 24 Nov 2023 00:49:02 +0300 Subject: [PATCH] rustc: Make `def_kind` mandatory for all `DefId`s --- clippy_lints/src/unused_async.rs | 2 +- clippy_lints/src/useless_conversion.rs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/clippy_lints/src/unused_async.rs b/clippy_lints/src/unused_async.rs index aea72c798be7..780ece3677df 100644 --- a/clippy_lints/src/unused_async.rs +++ b/clippy_lints/src/unused_async.rs @@ -148,7 +148,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAsync { // statements, so don't lint at all if there are any such paths. if let Some(def_id) = path.res.opt_def_id() && let Some(local_def_id) = def_id.as_local() - && let Some(DefKind::Fn) = cx.tcx.opt_def_kind(def_id) + && cx.tcx.def_kind(def_id) == DefKind::Fn && cx.tcx.asyncness(def_id).is_async() && !is_node_func_call(cx.tcx.hir().get_parent(hir_id), path.span) { diff --git a/clippy_lints/src/useless_conversion.rs b/clippy_lints/src/useless_conversion.rs index 52327b82e849..7aed1d6e30b4 100644 --- a/clippy_lints/src/useless_conversion.rs +++ b/clippy_lints/src/useless_conversion.rs @@ -4,7 +4,6 @@ use clippy_utils::sugg::Sugg; use clippy_utils::ty::{is_copy, is_type_diagnostic_item, same_type_and_consts}; use clippy_utils::{get_parent_expr, is_trait_method, is_ty_alias, path_to_local}; use rustc_errors::Applicability; -use rustc_hir::def::DefKind; use rustc_hir::def_id::DefId; use rustc_hir::{BindingAnnotation, Expr, ExprKind, HirId, MatchSource, Node, PatKind}; use rustc_infer::infer::TyCtxtInferExt; @@ -208,7 +207,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { && 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(DefKind::is_fn_like) => + && cx.tcx.def_kind(did).is_fn_like() => { Some(( did,