Skip to content

Commit feb18c3

Browse files
committed
Auto merge of #4082 - Manishearth:macro-check-split, r=oli-obk
Make most macro checks also check for desugarings We should audit the macro checks one by one and re-add `in_macro`. I suspect it's applicable to most of them. fixes rust-lang/rust-clippy#4081
2 parents 3710ec5 + abf6481 commit feb18c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+133
-118
lines changed

clippy_lints/src/assertions_on_constants.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc::{declare_lint_pass, declare_tool_lint};
55
use syntax_pos::Span;
66

77
use crate::consts::{constant, Constant};
8-
use crate::utils::{in_macro, is_direct_expn_of, span_help_and_lint};
8+
use crate::utils::{in_macro_or_desugar, is_direct_expn_of, span_help_and_lint};
99

1010
declare_clippy_lint! {
1111
/// **What it does:** Checks for `assert!(true)` and `assert!(false)` calls.
@@ -34,16 +34,16 @@ declare_lint_pass!(AssertionsOnConstants => [ASSERTIONS_ON_CONSTANTS]);
3434
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssertionsOnConstants {
3535
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
3636
let mut is_debug_assert = false;
37-
let debug_assert_not_in_macro = |span: Span| {
37+
let debug_assert_not_in_macro_or_desugar = |span: Span| {
3838
is_debug_assert = true;
3939
// Check that `debug_assert!` itself is not inside a macro
40-
!in_macro(span)
40+
!in_macro_or_desugar(span)
4141
};
4242
if_chain! {
4343
if let Some(assert_span) = is_direct_expn_of(e.span, "assert");
44-
if !in_macro(assert_span)
44+
if !in_macro_or_desugar(assert_span)
4545
|| is_direct_expn_of(assert_span, "debug_assert")
46-
.map_or(false, debug_assert_not_in_macro);
46+
.map_or(false, debug_assert_not_in_macro_or_desugar);
4747
if let ExprKind::Unary(_, ref lit) = e.node;
4848
if let Some(bool_const) = constant(cx, cx.tables, lit);
4949
then {

clippy_lints/src/attrs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::reexport::*;
44
use crate::utils::{
5-
in_macro, is_present_in_source, last_line_of_span, paths, snippet_opt, span_lint, span_lint_and_sugg,
5+
in_macro_or_desugar, is_present_in_source, last_line_of_span, paths, snippet_opt, span_lint, span_lint_and_sugg,
66
span_lint_and_then, without_block_comments,
77
};
88
use if_chain::if_chain;
@@ -408,7 +408,7 @@ fn is_relevant_expr(cx: &LateContext<'_, '_>, tables: &ty::TypeckTables<'_>, exp
408408
}
409409

410410
fn check_attrs(cx: &LateContext<'_, '_>, span: Span, name: Name, attrs: &[Attribute]) {
411-
if in_macro(span) {
411+
if in_macro_or_desugar(span) {
412412
return;
413413
}
414414

clippy_lints/src/block_in_if_condition.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
5454
if let ExprKind::Closure(_, _, eid, _, _) = expr.node {
5555
let body = self.cx.tcx.hir().body(eid);
5656
let ex = &body.value;
57-
if matches!(ex.node, ExprKind::Block(_, _)) && !in_macro(body.value.span) {
57+
if matches!(ex.node, ExprKind::Block(_, _)) && !in_macro_or_desugar(body.value.span) {
5858
self.found_block = Some(ex);
5959
return;
6060
}
@@ -79,7 +79,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlockInIfCondition {
7979
if let Some(ex) = &block.expr {
8080
// don't dig into the expression here, just suggest that they remove
8181
// the block
82-
if in_macro(expr.span) || differing_macro_contexts(expr.span, ex.span) {
82+
if in_macro_or_desugar(expr.span) || differing_macro_contexts(expr.span, ex.span) {
8383
return;
8484
}
8585
span_help_and_lint(
@@ -96,7 +96,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlockInIfCondition {
9696
}
9797
} else {
9898
let span = block.expr.as_ref().map_or_else(|| block.stmts[0].span, |e| e.span);
99-
if in_macro(span) || differing_macro_contexts(expr.span, span) {
99+
if in_macro_or_desugar(span) || differing_macro_contexts(expr.span, span) {
100100
return;
101101
}
102102
// move block higher

clippy_lints/src/booleans.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::utils::{
2-
get_trait_def_id, implements_trait, in_macro, match_type, paths, snippet_opt, span_lint_and_then, SpanlessEq,
2+
get_trait_def_id, implements_trait, in_macro, in_macro_or_desugar, match_type, paths, snippet_opt,
3+
span_lint_and_then, SpanlessEq,
34
};
45
use rustc::hir::intravisit::*;
56
use rustc::hir::*;
@@ -93,7 +94,7 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
9394

9495
fn run(&mut self, e: &'v Expr) -> Result<Bool, String> {
9596
// prevent folding of `cfg!` macros and the like
96-
if !in_macro(e.span) {
97+
if !in_macro_or_desugar(e.span) {
9798
match &e.node {
9899
ExprKind::Unary(UnNot, inner) => return Ok(Bool::Not(box self.run(inner)?)),
99100
ExprKind::Binary(binop, lhs, rhs) => match &binop.node {

clippy_lints/src/cognitive_complexity.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc::{declare_tool_lint, impl_lint_pass};
99
use syntax::ast::Attribute;
1010
use syntax::source_map::Span;
1111

12-
use crate::utils::{in_macro, is_allowed, match_type, paths, span_help_and_lint, LimitStack};
12+
use crate::utils::{in_macro_or_desugar, is_allowed, match_type, paths, span_help_and_lint, LimitStack};
1313

1414
declare_clippy_lint! {
1515
/// **What it does:** Checks for methods with high cognitive complexity.
@@ -42,7 +42,7 @@ impl_lint_pass!(CognitiveComplexity => [COGNITIVE_COMPLEXITY]);
4242

4343
impl CognitiveComplexity {
4444
fn check<'a, 'tcx: 'a>(&mut self, cx: &'a LateContext<'a, 'tcx>, body: &'tcx Body, span: Span) {
45-
if in_macro(span) {
45+
if in_macro_or_desugar(span) {
4646
return;
4747
}
4848

clippy_lints/src/collapsible_if.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ use rustc::{declare_lint_pass, declare_tool_lint};
1818
use syntax::ast;
1919

2020
use crate::utils::sugg::Sugg;
21-
use crate::utils::{in_macro, snippet_block, snippet_block_with_applicability, span_lint_and_sugg, span_lint_and_then};
21+
use crate::utils::{
22+
in_macro_or_desugar, snippet_block, snippet_block_with_applicability, span_lint_and_sugg, span_lint_and_then,
23+
};
2224
use rustc_errors::Applicability;
2325

2426
declare_clippy_lint! {
@@ -75,7 +77,7 @@ declare_lint_pass!(CollapsibleIf => [COLLAPSIBLE_IF]);
7577

7678
impl EarlyLintPass for CollapsibleIf {
7779
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) {
78-
if !in_macro(expr.span) {
80+
if !in_macro_or_desugar(expr.span) {
7981
check_if(cx, expr)
8082
}
8183
}
@@ -110,7 +112,7 @@ fn check_collapsible_maybe_if_let(cx: &EarlyContext<'_>, else_: &ast::Expr) {
110112
if let ast::ExprKind::Block(ref block, _) = else_.node;
111113
if !block_starts_with_comment(cx, block);
112114
if let Some(else_) = expr_block(block);
113-
if !in_macro(else_.span);
115+
if !in_macro_or_desugar(else_.span);
114116
then {
115117
match else_.node {
116118
ast::ExprKind::If(..) | ast::ExprKind::IfLet(..) => {

clippy_lints/src/const_static_lifetime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::utils::{in_macro, snippet, span_lint_and_then};
1+
use crate::utils::{in_macro_or_desugar, snippet, span_lint_and_then};
22
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
33
use rustc::{declare_lint_pass, declare_tool_lint};
44
use rustc_errors::Applicability;
@@ -81,7 +81,7 @@ impl StaticConst {
8181

8282
impl EarlyLintPass for StaticConst {
8383
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
84-
if !in_macro(item.span) {
84+
if !in_macro_or_desugar(item.span) {
8585
// Match only constants...
8686
if let ItemKind::Const(ref var_type, _) = item.node {
8787
self.visit_type(var_type, cx);

clippy_lints/src/copies.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::utils::{get_parent_expr, higher, in_macro, snippet, span_lint_and_then, span_note_and_lint};
1+
use crate::utils::{get_parent_expr, higher, in_macro_or_desugar, snippet, span_lint_and_then, span_note_and_lint};
22
use crate::utils::{SpanlessEq, SpanlessHash};
33
use rustc::hir::*;
44
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
@@ -107,7 +107,7 @@ declare_lint_pass!(CopyAndPaste => [IFS_SAME_COND, IF_SAME_THEN_ELSE, MATCH_SAME
107107

108108
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CopyAndPaste {
109109
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
110-
if !in_macro(expr.span) {
110+
if !in_macro_or_desugar(expr.span) {
111111
// skip ifs directly in else, it will be checked in the parent if
112112
if let Some(expr) = get_parent_expr(cx, expr) {
113113
if let Some((_, _, Some(ref else_expr))) = higher::if_block(&expr) {

clippy_lints/src/double_parens.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::utils::{in_macro, span_lint};
1+
use crate::utils::{in_macro_or_desugar, span_lint};
22
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
33
use rustc::{declare_lint_pass, declare_tool_lint};
44
use syntax::ast::*;
@@ -26,7 +26,7 @@ declare_lint_pass!(DoubleParens => [DOUBLE_PARENS]);
2626

2727
impl EarlyLintPass for DoubleParens {
2828
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
29-
if in_macro(expr.span) {
29+
if in_macro_or_desugar(expr.span) {
3030
return;
3131
}
3232

clippy_lints/src/enum_variants.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! lint on enum variants that are prefixed or suffixed by the same characters
22
3-
use crate::utils::{camel_case, in_macro, is_present_in_source};
3+
use crate::utils::{camel_case, in_macro_or_desugar, is_present_in_source};
44
use crate::utils::{span_help_and_lint, span_lint};
55
use rustc::lint::{EarlyContext, EarlyLintPass, Lint, LintArray, LintPass};
66
use rustc::{declare_tool_lint, impl_lint_pass};
@@ -244,7 +244,7 @@ impl EarlyLintPass for EnumVariantNames {
244244
let item_name = item.ident.as_str();
245245
let item_name_chars = item_name.chars().count();
246246
let item_camel = to_camel_case(&item_name);
247-
if !in_macro(item.span) && is_present_in_source(cx, item.span) {
247+
if !in_macro_or_desugar(item.span) && is_present_in_source(cx, item.span) {
248248
if let Some(&(ref mod_name, ref mod_camel)) = self.modules.last() {
249249
// constants don't have surrounding modules
250250
if !mod_camel.is_empty() {

clippy_lints/src/eq_op.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::utils::{
2-
implements_trait, in_macro, is_copy, multispan_sugg, snippet, span_lint, span_lint_and_then, SpanlessEq,
2+
implements_trait, in_macro_or_desugar, is_copy, multispan_sugg, snippet, span_lint, span_lint_and_then, SpanlessEq,
33
};
44
use rustc::hir::*;
55
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
@@ -52,7 +52,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
5252
#[allow(clippy::similar_names, clippy::too_many_lines)]
5353
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
5454
if let ExprKind::Binary(op, ref left, ref right) = e.node {
55-
if in_macro(e.span) {
55+
if in_macro_or_desugar(e.span) {
5656
return;
5757
}
5858
if is_valid_operator(op) && SpanlessEq::new(cx).ignore_fn().eq_expr(left, right) {

clippy_lints/src/erasing_op.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc::{declare_lint_pass, declare_tool_lint};
44
use syntax::source_map::Span;
55

66
use crate::consts::{constant_simple, Constant};
7-
use crate::utils::{in_macro, span_lint};
7+
use crate::utils::{in_macro_or_desugar, span_lint};
88

99
declare_clippy_lint! {
1010
/// **What it does:** Checks for erasing operations, e.g., `x * 0`.
@@ -31,7 +31,7 @@ declare_lint_pass!(ErasingOp => [ERASING_OP]);
3131

3232
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ErasingOp {
3333
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
34-
if in_macro(e.span) {
34+
if in_macro_or_desugar(e.span) {
3535
return;
3636
}
3737
if let ExprKind::Binary(ref cmp, ref left, ref right) = e.node {

clippy_lints/src/format.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::utils::paths;
22
use crate::utils::{
3-
in_macro, is_expn_of, last_path_segment, match_type, resolve_node, snippet, span_lint_and_then, walk_ptrs_ty,
3+
in_macro_or_desugar, is_expn_of, last_path_segment, match_type, resolve_node, snippet, span_lint_and_then,
4+
walk_ptrs_ty,
45
};
56
use if_chain::if_chain;
67
use rustc::hir::*;
@@ -38,7 +39,7 @@ declare_lint_pass!(UselessFormat => [USELESS_FORMAT]);
3839
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UselessFormat {
3940
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
4041
if let Some(span) = is_expn_of(expr.span, "format") {
41-
if in_macro(span) {
42+
if in_macro_or_desugar(span) {
4243
return;
4344
}
4445
match expr.node {

clippy_lints/src/formatting.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::utils::{differing_macro_contexts, in_macro, snippet_opt, span_note_and_lint};
1+
use crate::utils::{differing_macro_contexts, in_macro_or_desugar, snippet_opt, span_note_and_lint};
22
use if_chain::if_chain;
33
use rustc::lint::{in_external_macro, EarlyContext, EarlyLintPass, LintArray, LintPass};
44
use rustc::{declare_lint_pass, declare_tool_lint};
@@ -108,7 +108,7 @@ impl EarlyLintPass for Formatting {
108108
/// Implementation of the `SUSPICIOUS_ASSIGNMENT_FORMATTING` lint.
109109
fn check_assign(cx: &EarlyContext<'_>, expr: &ast::Expr) {
110110
if let ast::ExprKind::Assign(ref lhs, ref rhs) = expr.node {
111-
if !differing_macro_contexts(lhs.span, rhs.span) && !in_macro(lhs.span) {
111+
if !differing_macro_contexts(lhs.span, rhs.span) && !in_macro_or_desugar(lhs.span) {
112112
let eq_span = lhs.span.between(rhs.span);
113113
if let ast::ExprKind::Unary(op, ref sub_rhs) = rhs.node {
114114
if let Some(eq_snippet) = snippet_opt(cx, eq_span) {
@@ -140,7 +140,7 @@ fn check_else(cx: &EarlyContext<'_>, expr: &ast::Expr) {
140140
if let Some((then, &Some(ref else_))) = unsugar_if(expr);
141141
if is_block(else_) || unsugar_if(else_).is_some();
142142
if !differing_macro_contexts(then.span, else_.span);
143-
if !in_macro(then.span) && !in_external_macro(cx.sess, expr.span);
143+
if !in_macro_or_desugar(then.span) && !in_external_macro(cx.sess, expr.span);
144144

145145
// workaround for rust-lang/rust#43081
146146
if expr.span.lo().0 != 0 && expr.span.hi().0 != 0;
@@ -206,7 +206,7 @@ fn check_array(cx: &EarlyContext<'_>, expr: &ast::Expr) {
206206

207207
fn check_missing_else(cx: &EarlyContext<'_>, first: &ast::Expr, second: &ast::Expr) {
208208
if !differing_macro_contexts(first.span, second.span)
209-
&& !in_macro(first.span)
209+
&& !in_macro_or_desugar(first.span)
210210
&& unsugar_if(first).is_some()
211211
&& (is_block(second) || unsugar_if(second).is_some())
212212
{

clippy_lints/src/identity_conversion.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use crate::utils::{in_macro, match_trait_method, same_tys, snippet, snippet_with_macro_callsite, span_lint_and_then};
1+
use crate::utils::{
2+
in_macro_or_desugar, match_trait_method, same_tys, snippet, snippet_with_macro_callsite, span_lint_and_then,
3+
};
24
use crate::utils::{paths, resolve_node};
35
use rustc::hir::*;
46
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
@@ -31,7 +33,7 @@ impl_lint_pass!(IdentityConversion => [IDENTITY_CONVERSION]);
3133

3234
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
3335
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
34-
if in_macro(e.span) {
36+
if in_macro_or_desugar(e.span) {
3537
return;
3638
}
3739

clippy_lints/src/identity_op.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc::{declare_lint_pass, declare_tool_lint};
55
use syntax::source_map::Span;
66

77
use crate::consts::{constant_simple, Constant};
8-
use crate::utils::{clip, in_macro, snippet, span_lint, unsext};
8+
use crate::utils::{clip, in_macro_or_desugar, snippet, span_lint, unsext};
99

1010
declare_clippy_lint! {
1111
/// **What it does:** Checks for identity operations, e.g., `x + 0`.
@@ -28,7 +28,7 @@ declare_lint_pass!(IdentityOp => [IDENTITY_OP]);
2828

2929
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityOp {
3030
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
31-
if in_macro(e.span) {
31+
if in_macro_or_desugar(e.span) {
3232
return;
3333
}
3434
if let ExprKind::Binary(ref cmp, ref left, ref right) = e.node {

clippy_lints/src/implicit_return.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::utils::{in_macro, is_expn_of, snippet_opt, span_lint_and_then};
1+
use crate::utils::{in_macro_or_desugar, is_expn_of, snippet_opt, span_lint_and_then};
22
use rustc::hir::{intravisit::FnKind, Body, ExprKind, FnDecl, HirId, MatchSource};
33
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
44
use rustc::{declare_lint_pass, declare_tool_lint};
@@ -118,7 +118,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImplicitReturn {
118118

119119
// checking return type through MIR, HIR is not able to determine inferred closure return types
120120
// make sure it's not a macro
121-
if !mir.return_ty().is_unit() && !in_macro(span) {
121+
if !mir.return_ty().is_unit() && !in_macro_or_desugar(span) {
122122
Self::expr_match(cx, &body.value);
123123
}
124124
}

clippy_lints/src/items_after_statements.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! lint when items are used after statements
22
3-
use crate::utils::{in_macro, span_lint};
3+
use crate::utils::{in_macro_or_desugar, span_lint};
44
use matches::matches;
55
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
66
use rustc::{declare_lint_pass, declare_tool_lint};
@@ -38,7 +38,7 @@ declare_lint_pass!(ItemsAfterStatements => [ITEMS_AFTER_STATEMENTS]);
3838

3939
impl EarlyLintPass for ItemsAfterStatements {
4040
fn check_block(&mut self, cx: &EarlyContext<'_>, item: &Block) {
41-
if in_macro(item.span) {
41+
if in_macro_or_desugar(item.span) {
4242
return;
4343
}
4444

@@ -52,7 +52,7 @@ impl EarlyLintPass for ItemsAfterStatements {
5252
// lint on all further items
5353
for stmt in stmts {
5454
if let StmtKind::Item(ref it) = *stmt {
55-
if in_macro(it.span) {
55+
if in_macro_or_desugar(it.span) {
5656
return;
5757
}
5858
if let ItemKind::MacroDef(..) = it.node {

clippy_lints/src/len_zero.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use crate::utils::{get_item_name, in_macro, snippet_with_applicability, span_lint, span_lint_and_sugg, walk_ptrs_ty};
1+
use crate::utils::{
2+
get_item_name, in_macro_or_desugar, snippet_with_applicability, span_lint, span_lint_and_sugg, walk_ptrs_ty,
3+
};
24
use rustc::hir::def_id::DefId;
35
use rustc::hir::*;
46
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
@@ -73,7 +75,7 @@ declare_lint_pass!(LenZero => [LEN_ZERO, LEN_WITHOUT_IS_EMPTY]);
7375

7476
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LenZero {
7577
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
76-
if in_macro(item.span) {
78+
if in_macro_or_desugar(item.span) {
7779
return;
7880
}
7981

@@ -85,7 +87,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LenZero {
8587
}
8688

8789
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
88-
if in_macro(expr.span) {
90+
if in_macro_or_desugar(expr.span) {
8991
return;
9092
}
9193

0 commit comments

Comments
 (0)