File tree Expand file tree Collapse file tree 2 files changed +42
-12
lines changed Expand file tree Collapse file tree 2 files changed +42
-12
lines changed Original file line number Diff line number Diff line change @@ -495,18 +495,19 @@ struct NotSimplificationVisitor<'a, 'tcx> {
495
495
496
496
impl < ' a , ' tcx > Visitor < ' tcx > for NotSimplificationVisitor < ' a , ' tcx > {
497
497
fn visit_expr ( & mut self , expr : & ' tcx Expr < ' _ > ) {
498
- if let ExprKind :: Unary ( UnOp :: Not , inner) = & expr. kind {
499
- if let Some ( suggestion) = simplify_not ( self . cx , inner) {
500
- span_lint_and_sugg (
501
- self . cx ,
502
- NONMINIMAL_BOOL ,
503
- expr. span ,
504
- "this boolean expression can be simplified" ,
505
- "try" ,
506
- suggestion,
507
- Applicability :: MachineApplicable ,
508
- ) ;
509
- }
498
+ if let ExprKind :: Unary ( UnOp :: Not , inner) = & expr. kind &&
499
+ !inner. span . from_expansion ( ) &&
500
+ let Some ( suggestion) = simplify_not ( self . cx , inner)
501
+ {
502
+ span_lint_and_sugg (
503
+ self . cx ,
504
+ NONMINIMAL_BOOL ,
505
+ expr. span ,
506
+ "this boolean expression can be simplified" ,
507
+ "try" ,
508
+ suggestion,
509
+ Applicability :: MachineApplicable ,
510
+ ) ;
510
511
}
511
512
512
513
walk_expr ( self , expr) ;
Original file line number Diff line number Diff line change @@ -63,3 +63,32 @@ fn issue9428() {
63
63
println ! ( "foo" ) ;
64
64
}
65
65
}
66
+
67
+ fn issue_10523 ( ) {
68
+ macro_rules! a {
69
+ ( $v: expr) => {
70
+ $v. is_some( )
71
+ } ;
72
+ }
73
+ let x: Option < u32 > = None ;
74
+ if !a ! ( x) { }
75
+ }
76
+
77
+ fn issue_10523_1 ( ) {
78
+ macro_rules! a {
79
+ ( $v: expr) => {
80
+ !$v. is_some( )
81
+ } ;
82
+ }
83
+ let x: Option < u32 > = None ;
84
+ if a ! ( x) { }
85
+ }
86
+
87
+ fn issue_10523_2 ( ) {
88
+ macro_rules! a {
89
+ ( ) => {
90
+ !None :: <u32 >. is_some( )
91
+ } ;
92
+ }
93
+ if a ! ( ) { }
94
+ }
You can’t perform that action at this time.
0 commit comments