@@ -121,11 +121,9 @@ declare_lint_pass!(LenZero => [LEN_ZERO, LEN_WITHOUT_IS_EMPTY, COMPARISON_TO_EMP
121
121
122
122
impl < ' tcx > LateLintPass < ' tcx > for LenZero {
123
123
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
+ {
129
127
check_trait_items ( cx, item, trait_items) ;
130
128
}
131
129
}
@@ -162,17 +160,14 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
162
160
}
163
161
164
162
fn check_expr ( & mut self , cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' _ > ) {
165
- if expr. span . from_expansion ( ) {
166
- return ;
167
- }
168
-
169
163
if let ExprKind :: Let ( lt) = expr. kind
170
- && has_is_empty ( cx, lt. init )
171
164
&& match lt. pat . kind {
172
165
PatKind :: Slice ( [ ] , None , [ ] ) => true ,
173
166
PatKind :: Lit ( lit) if is_empty_string ( lit) => true ,
174
167
_ => false ,
175
168
}
169
+ && !expr. span . from_expansion ( )
170
+ && has_is_empty ( cx, lt. init )
176
171
{
177
172
let mut applicability = Applicability :: MachineApplicable ;
178
173
@@ -190,7 +185,9 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
190
185
) ;
191
186
}
192
187
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
+ {
194
191
// expr.span might contains parenthesis, see issue #10529
195
192
let actual_span = span_without_enclosing_paren ( cx, expr. span ) ;
196
193
match cmp {
0 commit comments