@@ -121,11 +121,9 @@ declare_lint_pass!(LenZero => [LEN_ZERO, LEN_WITHOUT_IS_EMPTY, COMPARISON_TO_EMP
121121
122122impl < ' tcx > LateLintPass < ' tcx > for LenZero {
123123 fn check_item ( & mut self , cx : & LateContext < ' tcx > , item : & ' tcx Item < ' _ > ) {
124- if item. span . from_expansion ( ) {
125- return ;
126- }
127-
128- if let ItemKind :: Trait ( _, _, _, _, trait_items) = item. kind {
124+ if let ItemKind :: Trait ( _, _, _, _, trait_items) = item. kind
125+ && !item. span . from_expansion ( )
126+ {
129127 check_trait_items ( cx, item, trait_items) ;
130128 }
131129 }
@@ -162,17 +160,14 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
162160 }
163161
164162 fn check_expr ( & mut self , cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' _ > ) {
165- if expr. span . from_expansion ( ) {
166- return ;
167- }
168-
169163 if let ExprKind :: Let ( lt) = expr. kind
170- && has_is_empty ( cx, lt. init )
171164 && match lt. pat . kind {
172165 PatKind :: Slice ( [ ] , None , [ ] ) => true ,
173166 PatKind :: Lit ( lit) if is_empty_string ( lit) => true ,
174167 _ => false ,
175168 }
169+ && !expr. span . from_expansion ( )
170+ && has_is_empty ( cx, lt. init )
176171 {
177172 let mut applicability = Applicability :: MachineApplicable ;
178173
@@ -190,7 +185,9 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
190185 ) ;
191186 }
192187
193- if let ExprKind :: Binary ( Spanned { node : cmp, .. } , left, right) = expr. kind {
188+ if let ExprKind :: Binary ( Spanned { node : cmp, .. } , left, right) = expr. kind
189+ && !expr. span . from_expansion ( )
190+ {
194191 // expr.span might contains parenthesis, see issue #10529
195192 let actual_span = span_without_enclosing_paren ( cx, expr. span ) ;
196193 match cmp {
0 commit comments