@@ -7,7 +7,7 @@ use rustc_ast::ast::LitKind;
7
7
use rustc_errors:: Applicability ;
8
8
use rustc_hir:: intravisit:: { walk_expr, FnKind , Visitor } ;
9
9
use rustc_hir:: { BinOpKind , Body , Expr , ExprKind , FnDecl , UnOp } ;
10
- use rustc_lint:: { LateContext , LateLintPass } ;
10
+ use rustc_lint:: { LateContext , LateLintPass , Level } ;
11
11
use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
12
12
use rustc_span:: def_id:: LocalDefId ;
13
13
use rustc_span:: source_map:: Span ;
@@ -430,23 +430,25 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
430
430
}
431
431
}
432
432
let nonminimal_bool_lint = |suggestions : Vec < _ > | {
433
- span_lint_hir_and_then (
434
- self . cx ,
435
- NONMINIMAL_BOOL ,
436
- e. hir_id ,
437
- e. span ,
438
- "this boolean expression can be simplified" ,
439
- |diag| {
440
- diag. span_suggestions (
441
- e. span ,
442
- "try" ,
443
- suggestions. into_iter ( ) ,
444
- // nonminimal_bool can produce minimal but
445
- // not human readable expressions (#3141)
446
- Applicability :: Unspecified ,
447
- ) ;
448
- } ,
449
- ) ;
433
+ if self . cx . tcx . lint_level_at_node ( NONMINIMAL_BOOL , e. hir_id ) . 0 != Level :: Allow {
434
+ span_lint_hir_and_then (
435
+ self . cx ,
436
+ NONMINIMAL_BOOL ,
437
+ e. hir_id ,
438
+ e. span ,
439
+ "this boolean expression can be simplified" ,
440
+ |diag| {
441
+ diag. span_suggestions (
442
+ e. span ,
443
+ "try" ,
444
+ suggestions. into_iter ( ) ,
445
+ // nonminimal_bool can produce minimal but
446
+ // not human readable expressions (#3141)
447
+ Applicability :: Unspecified ,
448
+ ) ;
449
+ } ,
450
+ ) ;
451
+ }
450
452
} ;
451
453
if improvements. is_empty ( ) {
452
454
let mut visitor = NotSimplificationVisitor { cx : self . cx } ;
@@ -498,6 +500,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NotSimplificationVisitor<'a, 'tcx> {
498
500
if let ExprKind :: Unary ( UnOp :: Not , inner) = & expr. kind &&
499
501
!inner. span . from_expansion ( ) &&
500
502
let Some ( suggestion) = simplify_not ( self . cx , inner)
503
+ && self . cx . tcx . lint_level_at_node ( NONMINIMAL_BOOL , expr. hir_id ) . 0 != Level :: Allow
501
504
{
502
505
span_lint_and_sugg (
503
506
self . cx ,
0 commit comments