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