1 use clippy_utils::diagnostics::span_lint_and_then;
2 use clippy_utils::source::snippet_with_macro_callsite;
3 use rustc_errors::Applicability;
4 use rustc_hir::{Stmt, StmtKind};
5 use rustc_lint::{LateContext, LintContext};
6 use rustc_middle::lint::in_external_macro;
8 use super::LET_UNIT_VALUE;
10 pub(super) fn check(cx: &LateContext<'_>, stmt: &Stmt<'_>) {
11 if let StmtKind::Local(local) = stmt.kind {
12 if cx.typeck_results().pat_ty(local.pat).is_unit() {
13 if in_external_macro(cx.sess(), stmt.span) || local.pat.span.from_expansion() {
20 "this let-binding has unit value",
22 if let Some(expr) = &local.init {
23 let snip = snippet_with_macro_callsite(cx, expr.span, "()");
26 "omit the `let` binding",
28 Applicability::MachineApplicable, // snippet