modify check that any macros will be ingored in this lint, and add test

This commit is contained in:
cocodery 2024-01-06 14:12:41 +08:00
parent 090c228873
commit bd6e9202b4
2 changed files with 12 additions and 2 deletions

View file

@ -499,11 +499,10 @@ struct NotSimplificationVisitor<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for NotSimplificationVisitor<'a, 'tcx> {
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
if let ExprKind::Unary(UnOp::Not, inner) = &expr.kind
&& !expr.span.from_expansion()
&& !inner.span.from_expansion()
&& let Some(suggestion) = simplify_not(self.cx, inner)
&& self.cx.tcx.lint_level_at_node(NONMINIMAL_BOOL, expr.hir_id).0 != Level::Allow
&& let Some(snippet) = snippet_opt(self.cx, expr.span)
&& !snippet.contains("assert")
{
span_lint_and_sugg(
self.cx,

View file

@ -145,3 +145,14 @@ fn issue10836() {
// Should not lint
let _: bool = !!Foo(true);
}
fn issue11932() {
let x: i32 = unimplemented!();
#[allow(clippy::nonminimal_bool)]
let _ = x % 2 == 0 || {
// Should not lint
assert!(x > 0);
x % 3 == 0
};
}