1 use clippy_utils::diagnostics::span_lint_and_then;
2 use rustc_errors::Applicability;
3 use rustc_hir::{Expr, Ty, TyKind};
4 use rustc_lint::LateContext;
7 use super::AS_UNDERSCORE;
9 pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, ty: &'tcx Ty<'_>) {
10 if matches!(ty.kind, TyKind::Infer) {
11 span_lint_and_then(cx, AS_UNDERSCORE, expr.span, "using `as _` conversion", |diag| {
12 let ty_resolved = cx.typeck_results().expr_ty(expr);
13 if let ty::Error(_) = ty_resolved.kind() {
14 diag.help("consider giving the type explicitly");
18 "consider giving the type explicitly",
20 Applicability::MachineApplicable,