1 use clippy_utils::diagnostics::span_lint;
2 use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
3 use rustc_hir::{Expr, ExprKind};
4 use rustc_lint::LateContext;
5 use rustc_middle::ty::{self, Ty};
7 use super::CAST_ENUM_CONSTRUCTOR;
9 pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cast_from: Ty<'_>) {
10 if matches!(cast_from.kind(), ty::FnDef(..))
11 && let ExprKind::Path(path) = &cast_expr.kind
12 && let Res::Def(DefKind::Ctor(CtorOf::Variant, CtorKind::Fn), _) = cx.qpath_res(path, cast_expr.hir_id)
16 CAST_ENUM_CONSTRUCTOR,
18 "cast of an enum tuple constructor to an integer",