-use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
+use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_hir_and_then};
use clippy_utils::source::snippet_opt;
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
use clippy_utils::{eq_expr_value, get_trait_def_id, paths};
///
/// ### Example
/// ```ignore
- /// if a && true // should be: if a
- /// if !(a == b) // should be: if a != b
+ /// if a && true {}
+ /// if !(a == b) {}
+ /// ```
+ ///
+ /// Use instead:
+ /// ```rust,ignore
+ /// if a {}
+ /// if a != b {}
/// ```
#[clippy::version = "pre 1.29.0"]
pub NONMINIMAL_BOOL,
/// Ignores short circuiting behavior.
///
/// ### Example
- /// ```ignore
+ /// ```rust,ignore
+ /// // The `b` is unnecessary, the expression is equivalent to `if a`.
/// if a && b || a { ... }
/// ```
- /// The `b` is unnecessary, the expression is equivalent to `if a`.
+ ///
+ /// Use instead:
+ /// ```rust,ignore
+ /// if a {}
+ /// ```
#[clippy::version = "pre 1.29.0"]
pub LOGIC_BUG,
correctness,
continue 'simplified;
}
if stats.terminals[i] != 0 && simplified_stats.terminals[i] == 0 {
- span_lint_and_then(
+ span_lint_hir_and_then(
self.cx,
LOGIC_BUG,
+ e.hir_id,
e.span,
"this boolean expression contains a logic bug",
|diag| {
}
}
let nonminimal_bool_lint = |suggestions: Vec<_>| {
- span_lint_and_then(
+ span_lint_hir_and_then(
self.cx,
NONMINIMAL_BOOL,
+ e.hir_id,
e.span,
"this boolean expression can be simplified",
|diag| {