1 use clippy_utils::diagnostics::span_lint;
2 use rustc_hir::{BinOpKind, Expr, ExprKind};
3 use rustc_lint::LateContext;
4 use rustc_span::hygiene::{ExpnKind, MacroKind};
8 pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
9 if expr.span.from_expansion() {
10 if let Some(callee) = expr.span.source_callee() {
11 if let ExpnKind::Macro(MacroKind::Bang, symbol) = callee.kind {
12 if let ExprKind::Binary(ref cmp, left, _) = expr.kind {
14 if op.is_comparison() && cx.typeck_results().expr_ty(left).is_unit() {
15 let result = match &*symbol.as_str() {
16 "assert_eq" | "debug_assert_eq" => "succeed",
17 "assert_ne" | "debug_assert_ne" => "fail",
25 "`{}` of unit values detected. This will always {}",
37 if let ExprKind::Binary(ref cmp, left, _) = expr.kind {
39 if op.is_comparison() && cx.typeck_results().expr_ty(left).is_unit() {
40 let result = match op {
41 BinOpKind::Eq | BinOpKind::Le | BinOpKind::Ge => "true",
49 "{}-comparison of unit values detected. This will always be {}",