Auto merge of #118250 - petrochenkov:optdefkind, r=compiler-errors

rustc: Make `def_kind` mandatory for all `DefId`s

Prerequisite for https://github.com/rust-lang/rust/pull/118188.
This commit is contained in:
bors 2023-11-26 04:44:20 +00:00
commit a79a7d6510
2 changed files with 2 additions and 3 deletions

View file

@ -148,7 +148,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAsync {
// statements, so don't lint at all if there are any such paths. // statements, so don't lint at all if there are any such paths.
if let Some(def_id) = path.res.opt_def_id() if let Some(def_id) = path.res.opt_def_id()
&& let Some(local_def_id) = def_id.as_local() && 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() && cx.tcx.asyncness(def_id).is_async()
&& !is_node_func_call(cx.tcx.hir().get_parent(hir_id), path.span) && !is_node_func_call(cx.tcx.hir().get_parent(hir_id), path.span)
{ {

View file

@ -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::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 clippy_utils::{get_parent_expr, is_trait_method, is_ty_alias, path_to_local};
use rustc_errors::Applicability; use rustc_errors::Applicability;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_hir::{BindingAnnotation, Expr, ExprKind, HirId, MatchSource, Node, PatKind}; use rustc_hir::{BindingAnnotation, Expr, ExprKind, HirId, MatchSource, Node, PatKind};
use rustc_infer::infer::TyCtxtInferExt; 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() && 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 // make sure that the path indeed points to a fn-like item, so that
// `fn_sig` does not ICE. (see #11065) // `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(( Some((
did, did,