@@ -7,7 +7,7 @@ use rustc_ast::ast::LitKind;
77use rustc_errors:: Applicability ;
88use rustc_hir:: intravisit:: { walk_expr, FnKind , Visitor } ;
99use rustc_hir:: { BinOpKind , Body , Expr , ExprKind , FnDecl , UnOp } ;
10- use rustc_lint:: { LateContext , LateLintPass } ;
10+ use rustc_lint:: { LateContext , LateLintPass , Level } ;
1111use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
1212use rustc_span:: def_id:: LocalDefId ;
1313use rustc_span:: source_map:: Span ;
@@ -430,23 +430,25 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
430430 }
431431 }
432432 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+ }
450452 } ;
451453 if improvements. is_empty ( ) {
452454 let mut visitor = NotSimplificationVisitor { cx : self . cx } ;
@@ -498,6 +500,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NotSimplificationVisitor<'a, 'tcx> {
498500 if let ExprKind :: Unary ( UnOp :: Not , inner) = & expr. kind &&
499501 !inner. span . from_expansion ( ) &&
500502 let Some ( suggestion) = simplify_not ( self . cx , inner)
503+ && self . cx . tcx . lint_level_at_node ( NONMINIMAL_BOOL , expr. hir_id ) . 0 != Level :: Allow
501504 {
502505 span_lint_and_sugg (
503506 self . cx ,
0 commit comments