Skip to content

Commit 9a60a93

Browse files
committed
Auto merge of rust-lang#7897 - camsteffen:in-macro, r=flip1995
Replace `in_macro` usage with `from_expansion` changelog: none Generally replace `in_macro(span)` with `span.from_expansion()`. If we're just trying to avoid expanded code, this seems more appropriate because any kind of expanded code is prone to false positives. One place I did not touch is `macro_use.rs`. I think this lint could use a rewrite so I moved `in_macro` there, the only place it is still used.
2 parents 85e2592 + 5b1b6a2 commit 9a60a93

Some content is hidden

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

46 files changed

+194
-208
lines changed

clippy_lints/src/booleans.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
22
use clippy_utils::source::snippet_opt;
33
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
4-
use clippy_utils::{eq_expr_value, get_trait_def_id, in_macro, paths};
4+
use clippy_utils::{eq_expr_value, get_trait_def_id, paths};
55
use if_chain::if_chain;
66
use rustc_ast::ast::LitKind;
77
use rustc_errors::Applicability;
@@ -453,22 +453,20 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
453453
type Map = Map<'tcx>;
454454

455455
fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
456-
if in_macro(e.span) {
457-
return;
458-
}
459-
match &e.kind {
460-
ExprKind::Binary(binop, _, _) if binop.node == BinOpKind::Or || binop.node == BinOpKind::And => {
461-
self.bool_expr(e);
462-
},
463-
ExprKind::Unary(UnOp::Not, inner) => {
464-
if self.cx.typeck_results().node_types()[inner.hir_id].is_bool() {
456+
if !e.span.from_expansion() {
457+
match &e.kind {
458+
ExprKind::Binary(binop, _, _) if binop.node == BinOpKind::Or || binop.node == BinOpKind::And => {
465459
self.bool_expr(e);
466-
} else {
467-
walk_expr(self, e);
468-
}
469-
},
470-
_ => walk_expr(self, e),
460+
},
461+
ExprKind::Unary(UnOp::Not, inner) => {
462+
if self.cx.typeck_results().node_types()[inner.hir_id].is_bool() {
463+
self.bool_expr(e);
464+
}
465+
},
466+
_ => {},
467+
}
471468
}
469+
walk_expr(self, e);
472470
}
473471
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
474472
NestedVisitorMap::None

clippy_lints/src/copies.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use clippy_utils::diagnostics::{span_lint_and_note, span_lint_and_then};
22
use clippy_utils::source::{first_line_of_span, indent_of, reindent_multiline, snippet, snippet_opt};
33
use clippy_utils::{
4-
both, count_eq, eq_expr_value, get_enclosing_block, get_parent_expr, if_sequence, in_macro, is_else_clause,
5-
is_lint_allowed, search_same, ContainsName, SpanlessEq, SpanlessHash,
4+
both, count_eq, eq_expr_value, get_enclosing_block, get_parent_expr, if_sequence, is_else_clause, is_lint_allowed,
5+
search_same, ContainsName, SpanlessEq, SpanlessHash,
66
};
77
use if_chain::if_chain;
88
use rustc_data_structures::fx::FxHashSet;
@@ -623,7 +623,7 @@ fn lint_same_fns_in_if_cond(cx: &LateContext<'_>, conds: &[&Expr<'_>]) {
623623

624624
let eq: &dyn Fn(&&Expr<'_>, &&Expr<'_>) -> bool = &|&lhs, &rhs| -> bool {
625625
// Do not lint if any expr originates from a macro
626-
if in_macro(lhs.span) || in_macro(rhs.span) {
626+
if lhs.span.from_expansion() || rhs.span.from_expansion() {
627627
return false;
628628
}
629629
// Do not spawn warning if `IFS_SAME_COND` already produced it.

clippy_lints/src/default.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::{span_lint_and_note, span_lint_and_sugg};
22
use clippy_utils::source::snippet_with_macro_callsite;
33
use clippy_utils::ty::{has_drop, is_copy};
4-
use clippy_utils::{any_parent_is_automatically_derived, contains_name, in_macro, match_def_path, paths};
4+
use clippy_utils::{any_parent_is_automatically_derived, contains_name, match_def_path, paths};
55
use if_chain::if_chain;
66
use rustc_data_structures::fx::FxHashSet;
77
use rustc_errors::Applicability;
@@ -78,7 +78,7 @@ impl_lint_pass!(Default => [DEFAULT_TRAIT_ACCESS, FIELD_REASSIGN_WITH_DEFAULT]);
7878
impl LateLintPass<'_> for Default {
7979
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
8080
if_chain! {
81-
if !in_macro(expr.span);
81+
if !expr.span.from_expansion();
8282
// Avoid cases already linted by `field_reassign_with_default`
8383
if !self.reassigned_linted.contains(&expr.span);
8484
if let ExprKind::Call(path, ..) = expr.kind;
@@ -125,7 +125,7 @@ impl LateLintPass<'_> for Default {
125125
if let StmtKind::Local(local) = stmt.kind;
126126
if let Some(expr) = local.init;
127127
if !any_parent_is_automatically_derived(cx.tcx, expr.hir_id);
128-
if !in_macro(expr.span);
128+
if !expr.span.from_expansion();
129129
// only take bindings to identifiers
130130
if let PatKind::Binding(_, binding_id, ident, _) = local.pat.kind;
131131
// only when assigning `... = Default::default()`

clippy_lints/src/dereference.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::span_lint_and_sugg;
22
use clippy_utils::source::snippet_with_context;
33
use clippy_utils::ty::peel_mid_ty_refs;
4-
use clippy_utils::{get_parent_node, in_macro, is_lint_allowed};
4+
use clippy_utils::{get_parent_node, is_lint_allowed};
55
use rustc_ast::util::parser::PREC_PREFIX;
66
use rustc_errors::Applicability;
77
use rustc_hir::{BorrowKind, Expr, ExprKind, HirId, MatchSource, Mutability, Node, UnOp};
@@ -84,7 +84,7 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing {
8484
}
8585

8686
// Stop processing sub expressions when a macro call is seen
87-
if in_macro(expr.span) {
87+
if expr.span.from_expansion() {
8888
if let Some((state, data)) = self.state.take() {
8989
report(cx, expr, state, data);
9090
}

clippy_lints/src/derivable_impls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
2-
use clippy_utils::{in_macro, is_automatically_derived, is_default_equivalent, remove_blocks};
2+
use clippy_utils::{is_automatically_derived, is_default_equivalent, remove_blocks};
33
use rustc_hir::{
44
def::{DefKind, Res},
55
Body, Expr, ExprKind, GenericArg, Impl, ImplItemKind, Item, ItemKind, Node, PathSegment, QPath, TyKind,
@@ -72,7 +72,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
7272
}) = item.kind;
7373
if let attrs = cx.tcx.hir().attrs(item.hir_id());
7474
if !is_automatically_derived(attrs);
75-
if !in_macro(item.span);
75+
if !item.span.from_expansion();
7676
if let Some(def_id) = trait_ref.trait_def_id();
7777
if cx.tcx.is_diagnostic_item(sym::Default, def_id);
7878
if let impl_item_hir = child.id.hir_id();

clippy_lints/src/eq_op.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use clippy_utils::diagnostics::{multispan_sugg, span_lint, span_lint_and_then};
22
use clippy_utils::source::snippet;
33
use clippy_utils::ty::{implements_trait, is_copy};
4-
use clippy_utils::{
5-
ast_utils::is_useless_with_eq_exprs, eq_expr_value, higher, in_macro, is_expn_of, is_in_test_function,
6-
};
4+
use clippy_utils::{ast_utils::is_useless_with_eq_exprs, eq_expr_value, higher, is_expn_of, is_in_test_function};
75
use if_chain::if_chain;
86
use rustc_errors::Applicability;
97
use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, StmtKind};
@@ -102,7 +100,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp {
102100
}
103101
let macro_with_not_op = |expr_kind: &ExprKind<'_>| {
104102
if let ExprKind::Unary(_, expr) = *expr_kind {
105-
in_macro(expr.span)
103+
expr.span.from_expansion()
106104
} else {
107105
false
108106
}

clippy_lints/src/excessive_bools.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
2-
use clippy_utils::in_macro;
32
use rustc_ast::ast::{AssocItemKind, Extern, FnKind, FnSig, ImplKind, Item, ItemKind, TraitKind, Ty, TyKind};
43
use rustc_lint::{EarlyContext, EarlyLintPass};
54
use rustc_session::{declare_tool_lint, impl_lint_pass};
@@ -135,7 +134,7 @@ fn is_bool_ty(ty: &Ty) -> bool {
135134

136135
impl EarlyLintPass for ExcessiveBools {
137136
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
138-
if in_macro(item.span) {
137+
if item.span.from_expansion() {
139138
return;
140139
}
141140
match &item.kind {

clippy_lints/src/implicit_saturating_sub.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clippy_utils::diagnostics::span_lint_and_sugg;
22
use clippy_utils::higher;
3-
use clippy_utils::{in_macro, SpanlessEq};
3+
use clippy_utils::SpanlessEq;
44
use if_chain::if_chain;
55
use rustc_ast::ast::LitKind;
66
use rustc_errors::Applicability;
@@ -39,7 +39,7 @@ declare_lint_pass!(ImplicitSaturatingSub => [IMPLICIT_SATURATING_SUB]);
3939

4040
impl<'tcx> LateLintPass<'tcx> for ImplicitSaturatingSub {
4141
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
42-
if in_macro(expr.span) {
42+
if expr.span.from_expansion() {
4343
return;
4444
}
4545
if_chain! {

clippy_lints/src/inconsistent_struct_constructor.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use clippy_utils::diagnostics::span_lint_and_sugg;
2-
use clippy_utils::in_macro;
32
use clippy_utils::source::snippet;
43
use if_chain::if_chain;
54
use rustc_data_structures::fx::FxHashMap;
@@ -66,7 +65,7 @@ declare_lint_pass!(InconsistentStructConstructor => [INCONSISTENT_STRUCT_CONSTRU
6665
impl LateLintPass<'_> for InconsistentStructConstructor {
6766
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
6867
if_chain! {
69-
if !in_macro(expr.span);
68+
if !expr.span.from_expansion();
7069
if let ExprKind::Struct(qpath, fields, base) = expr.kind;
7170
let ty = cx.typeck_results().expr_ty(expr);
7271
if let Some(adt_def) = ty.ty_adt_def();

clippy_lints/src/inherent_impl.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! lint on inherent implementations
22
33
use clippy_utils::diagnostics::span_lint_and_note;
4-
use clippy_utils::{in_macro, is_lint_allowed};
4+
use clippy_utils::is_lint_allowed;
55
use rustc_data_structures::fx::FxHashMap;
66
use rustc_hir::{def_id::LocalDefId, Item, ItemKind, Node};
77
use rustc_lint::{LateContext, LateLintPass};
@@ -123,8 +123,10 @@ fn get_impl_span(cx: &LateContext<'_>, id: LocalDefId) -> Option<Span> {
123123
..
124124
}) = cx.tcx.hir().get(id)
125125
{
126-
(!in_macro(span) && impl_item.generics.params.is_empty() && !is_lint_allowed(cx, MULTIPLE_INHERENT_IMPL, id))
127-
.then(|| span)
126+
(!span.from_expansion()
127+
&& impl_item.generics.params.is_empty()
128+
&& !is_lint_allowed(cx, MULTIPLE_INHERENT_IMPL, id))
129+
.then(|| span)
128130
} else {
129131
None
130132
}

clippy_lints/src/lifetimes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use clippy_utils::diagnostics::span_lint;
2-
use clippy_utils::{in_macro, trait_ref_of_method};
2+
use clippy_utils::trait_ref_of_method;
33
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
44
use rustc_hir::intravisit::{
55
walk_fn_decl, walk_generic_param, walk_generics, walk_item, walk_param_bound, walk_poly_trait_ref, walk_ty,
@@ -128,7 +128,7 @@ fn check_fn_inner<'tcx>(
128128
span: Span,
129129
report_extra_lifetimes: bool,
130130
) {
131-
if in_macro(span) || has_where_lifetimes(cx, &generics.where_clause) {
131+
if span.from_expansion() || has_where_lifetimes(cx, &generics.where_clause) {
132132
return;
133133
}
134134

clippy_lints/src/literal_representation.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22
//! floating-point literal expressions.
33
44
use clippy_utils::diagnostics::span_lint_and_sugg;
5+
use clippy_utils::numeric_literal::{NumericLiteral, Radix};
56
use clippy_utils::source::snippet_opt;
6-
use clippy_utils::{
7-
in_macro,
8-
numeric_literal::{NumericLiteral, Radix},
9-
};
107
use if_chain::if_chain;
118
use rustc_ast::ast::{Expr, ExprKind, Lit, LitKind};
129
use rustc_errors::Applicability;
@@ -283,7 +280,7 @@ impl LiteralDigitGrouping {
283280
| WarningType::InconsistentDigitGrouping
284281
| WarningType::UnusualByteGroupings
285282
| WarningType::LargeDigitGroups => {
286-
!in_macro(lit.span)
283+
!lit.span.from_expansion()
287284
}
288285
WarningType::DecimalRepresentation | WarningType::MistypedLiteralSuffix => {
289286
true

clippy_lints/src/macro_use.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use clippy_utils::diagnostics::span_lint_and_sugg;
2-
use clippy_utils::in_macro;
32
use clippy_utils::source::snippet;
43
use hir::def::{DefKind, Res};
54
use if_chain::if_chain;
@@ -9,6 +8,7 @@ use rustc_errors::Applicability;
98
use rustc_hir as hir;
109
use rustc_lint::{LateContext, LateLintPass, LintContext};
1110
use rustc_session::{declare_tool_lint, impl_lint_pass};
11+
use rustc_span::hygiene::ExpnKind;
1212
use rustc_span::{edition::Edition, sym, Span};
1313

1414
declare_clippy_lint! {
@@ -213,3 +213,7 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports {
213213
}
214214
}
215215
}
216+
217+
fn in_macro(span: Span) -> bool {
218+
span.from_expansion() && !matches!(span.ctxt().outer_expn_data().kind, ExpnKind::Desugaring(..))
219+
}

clippy_lints/src/matches.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use clippy_utils::sugg::Sugg;
88
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item, match_type, peel_mid_ty_refs};
99
use clippy_utils::visitors::is_local_used;
1010
use clippy_utils::{
11-
get_parent_expr, in_macro, is_expn_of, is_lang_ctor, is_lint_allowed, is_refutable, is_unit_expr, is_wild,
12-
meets_msrv, msrvs, path_to_local, path_to_local_id, peel_hir_pat_refs, peel_n_hir_expr_refs, recurse_or_patterns,
13-
remove_blocks, strip_pat_refs,
11+
get_parent_expr, is_expn_of, is_lang_ctor, is_lint_allowed, is_refutable, is_unit_expr, is_wild, meets_msrv, msrvs,
12+
path_to_local, path_to_local_id, peel_hir_pat_refs, peel_n_hir_expr_refs, recurse_or_patterns, remove_blocks,
13+
strip_pat_refs,
1414
};
1515
use clippy_utils::{paths, search_same, SpanlessEq, SpanlessHash};
1616
use core::array;
@@ -26,7 +26,6 @@ use rustc_hir::{
2626
};
2727
use rustc_hir::{HirIdMap, HirIdSet};
2828
use rustc_lint::{LateContext, LateLintPass, LintContext};
29-
use rustc_middle::lint::in_external_macro;
3029
use rustc_middle::ty::{self, Ty, TyS, VariantDef};
3130
use rustc_semver::RustcVersion;
3231
use rustc_session::{declare_tool_lint, impl_lint_pass};
@@ -601,7 +600,7 @@ impl_lint_pass!(Matches => [
601600

602601
impl<'tcx> LateLintPass<'tcx> for Matches {
603602
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
604-
if in_external_macro(cx.sess(), expr.span) || in_macro(expr.span) {
603+
if expr.span.from_expansion() {
605604
return;
606605
}
607606

@@ -640,8 +639,7 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
640639

641640
fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx Local<'_>) {
642641
if_chain! {
643-
if !in_external_macro(cx.sess(), local.span);
644-
if !in_macro(local.span);
642+
if !local.span.from_expansion();
645643
if let Some(expr) = local.init;
646644
if let ExprKind::Match(target, arms, MatchSource::Normal) = expr.kind;
647645
if arms.len() == 1 && arms[0].guard.is_none();
@@ -676,8 +674,7 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
676674

677675
fn check_pat(&mut self, cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>) {
678676
if_chain! {
679-
if !in_external_macro(cx.sess(), pat.span);
680-
if !in_macro(pat.span);
677+
if !pat.span.from_expansion();
681678
if let PatKind::Struct(QPath::Resolved(_, path), fields, true) = pat.kind;
682679
if let Some(def_id) = path.res.opt_def_id();
683680
let ty = cx.tcx.type_of(def_id);
@@ -704,7 +701,7 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
704701
#[rustfmt::skip]
705702
fn check_single_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr: &Expr<'_>) {
706703
if arms.len() == 2 && arms[0].guard.is_none() && arms[1].guard.is_none() {
707-
if in_macro(expr.span) {
704+
if expr.span.from_expansion() {
708705
// Don't lint match expressions present in
709706
// macro_rules! block
710707
return;
@@ -1447,7 +1444,7 @@ fn find_bool_lit(ex: &ExprKind<'_>, is_if_let: bool) -> Option<bool> {
14471444

14481445
#[allow(clippy::too_many_lines)]
14491446
fn check_match_single_binding<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[Arm<'_>], expr: &Expr<'_>) {
1450-
if in_macro(expr.span) || arms.len() != 1 || is_refutable(cx, arms[0].pat) {
1447+
if expr.span.from_expansion() || arms.len() != 1 || is_refutable(cx, arms[0].pat) {
14511448
return;
14521449
}
14531450

clippy_lints/src/mem_replace.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg, span_lint_and_then};
22
use clippy_utils::source::{snippet, snippet_with_applicability};
33
use clippy_utils::ty::is_non_aggregate_primitive_type;
4-
use clippy_utils::{in_macro, is_default_equivalent, is_lang_ctor, match_def_path, meets_msrv, msrvs, paths};
4+
use clippy_utils::{is_default_equivalent, is_lang_ctor, match_def_path, meets_msrv, msrvs, paths};
55
use if_chain::if_chain;
66
use rustc_errors::Applicability;
77
use rustc_hir::LangItem::OptionNone;
@@ -213,7 +213,7 @@ fn check_replace_with_default(cx: &LateContext<'_>, src: &Expr<'_>, dest: &Expr<
213213
expr_span,
214214
"replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`",
215215
|diag| {
216-
if !in_macro(expr_span) {
216+
if !expr_span.from_expansion() {
217217
let suggestion = format!("std::mem::take({})", snippet(cx, dest.span, ""));
218218

219219
diag.span_suggestion(

clippy_lints/src/methods/bind_instead_of_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::{contains_return, BIND_INSTEAD_OF_MAP};
22
use clippy_utils::diagnostics::{multispan_sugg_with_applicability, span_lint_and_sugg, span_lint_and_then};
33
use clippy_utils::source::{snippet, snippet_with_macro_callsite};
4-
use clippy_utils::{in_macro, remove_blocks, visitors::find_all_ret_expressions};
4+
use clippy_utils::{remove_blocks, visitors::find_all_ret_expressions};
55
use if_chain::if_chain;
66
use rustc_errors::Applicability;
77
use rustc_hir as hir;
@@ -106,7 +106,7 @@ pub(crate) trait BindInsteadOfMap {
106106
let mut suggs = Vec::new();
107107
let can_sugg: bool = find_all_ret_expressions(cx, closure_expr, |ret_expr| {
108108
if_chain! {
109-
if !in_macro(ret_expr.span);
109+
if !ret_expr.span.from_expansion();
110110
if let hir::ExprKind::Call(func_path, [arg]) = ret_expr.kind;
111111
if let hir::ExprKind::Path(QPath::Resolved(_, path)) = func_path.kind;
112112
if Self::is_variant(cx, path.res);

clippy_lints/src/methods/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ use bind_instead_of_map::BindInsteadOfMap;
6868
use clippy_utils::consts::{constant, Constant};
6969
use clippy_utils::diagnostics::{span_lint, span_lint_and_help};
7070
use clippy_utils::ty::{contains_adt_constructor, contains_ty, implements_trait, is_copy, is_type_diagnostic_item};
71-
use clippy_utils::{contains_return, get_trait_def_id, in_macro, iter_input_pats, meets_msrv, msrvs, paths, return_ty};
71+
use clippy_utils::{contains_return, get_trait_def_id, iter_input_pats, meets_msrv, msrvs, paths, return_ty};
7272
use if_chain::if_chain;
7373
use rustc_hir as hir;
7474
use rustc_hir::def::Res;
@@ -1900,7 +1900,7 @@ macro_rules! method_call {
19001900

19011901
impl<'tcx> LateLintPass<'tcx> for Methods {
19021902
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
1903-
if in_macro(expr.span) {
1903+
if expr.span.from_expansion() {
19041904
return;
19051905
}
19061906

0 commit comments

Comments
 (0)