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 {
12 kind: MacroKind::Bang,
17 if let ExprKind::Binary(ref cmp, left, _) = expr.kind {
19 if op.is_comparison() && cx.typeck_results().expr_ty(left).is_unit() {
20 let result = match &*symbol.as_str() {
21 "assert_eq" | "debug_assert_eq" => "succeed",
22 "assert_ne" | "debug_assert_ne" => "fail",
30 "`{}` of unit values detected. This will always {}",
42 if let ExprKind::Binary(ref cmp, left, _) = expr.kind {
44 if op.is_comparison() && cx.typeck_results().expr_ty(left).is_unit() {
45 let result = match op {
46 BinOpKind::Eq | BinOpKind::Le | BinOpKind::Ge => "true",
54 "{}-comparison of unit values detected. This will always be {}",