Skip to content

Commit 204b2f3

Browse files
committed
Remove in_macro_or_desugar
1 parent 918d609 commit 204b2f3

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

+129
-148
lines changed

clippy_lints/src/assertions_on_constants.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
33
use rustc::{declare_lint_pass, declare_tool_lint};
44

55
use crate::consts::{constant, Constant};
6-
use crate::utils::{in_macro_or_desugar, is_direct_expn_of, is_expn_of, span_help_and_lint};
6+
use crate::utils::{is_direct_expn_of, is_expn_of, span_help_and_lint};
77

88
declare_clippy_lint! {
99
/// **What it does:** Checks for `assert!(true)` and `assert!(false)` calls.
@@ -55,12 +55,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssertionsOnConstants {
5555
}
5656
};
5757
if let Some(debug_assert_span) = is_expn_of(e.span, "debug_assert") {
58-
if in_macro_or_desugar(debug_assert_span) {
58+
if debug_assert_span.from_expansion() {
5959
return;
6060
}
6161
lint_assert_cb(true);
6262
} else if let Some(assert_span) = is_direct_expn_of(e.span, "assert") {
63-
if in_macro_or_desugar(assert_span) {
63+
if assert_span.from_expansion() {
6464
return;
6565
}
6666
lint_assert_cb(false);

clippy_lints/src/attrs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
use crate::reexport::*;
44
use crate::utils::{
5-
in_macro_or_desugar, is_present_in_source, last_line_of_span, match_def_path, paths, snippet_opt, span_lint,
6-
span_lint_and_sugg, span_lint_and_then, without_block_comments,
5+
is_present_in_source, last_line_of_span, match_def_path, paths, snippet_opt, span_lint, span_lint_and_sugg,
6+
span_lint_and_then, without_block_comments,
77
};
88
use if_chain::if_chain;
99
use rustc::hir::*;
@@ -412,7 +412,7 @@ fn is_relevant_expr(cx: &LateContext<'_, '_>, tables: &ty::TypeckTables<'_>, exp
412412
}
413413

414414
fn check_attrs(cx: &LateContext<'_, '_>, span: Span, name: Name, attrs: &[Attribute]) {
415-
if in_macro_or_desugar(span) {
415+
if span.from_expansion() {
416416
return;
417417
}
418418

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> 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_or_desugar(body.value.span) {
57+
if matches!(ex.node, ExprKind::Block(_, _)) && !body.value.span.from_expansion() {
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_or_desugar(expr.span) || differing_macro_contexts(expr.span, ex.span) {
82+
if expr.span.from_expansion() || 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_or_desugar(span) || differing_macro_contexts(expr.span, span) {
99+
if span.from_expansion() || differing_macro_contexts(expr.span, span) {
100100
return;
101101
}
102102
// move block higher

clippy_lints/src/booleans.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::utils::{
2-
get_trait_def_id, implements_trait, in_macro, in_macro_or_desugar, match_type, paths, snippet_opt,
3-
span_lint_and_then, SpanlessEq,
2+
get_trait_def_id, implements_trait, in_macro, match_type, paths, snippet_opt, span_lint_and_then, SpanlessEq,
43
};
54
use if_chain::if_chain;
65
use rustc::hir::intravisit::*;
@@ -106,7 +105,7 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
106105
}
107106

108107
// prevent folding of `cfg!` macros and the like
109-
if !in_macro_or_desugar(e.span) {
108+
if !e.span.from_expansion() {
110109
match &e.node {
111110
ExprKind::Unary(UnNot, inner) => return Ok(Bool::Not(box self.run(inner)?)),
112111
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_or_desugar, is_allowed, match_type, paths, span_help_and_lint, LimitStack};
12+
use crate::utils::{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>(&mut self, cx: &'a LateContext<'a, 'tcx>, body: &'tcx Body, span: Span) {
45-
if in_macro_or_desugar(span) {
45+
if span.from_expansion() {
4646
return;
4747
}
4848

clippy_lints/src/collapsible_if.rs

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

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

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

7876
impl EarlyLintPass for CollapsibleIf {
7977
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) {
80-
if !in_macro_or_desugar(expr.span) {
78+
if !expr.span.from_expansion() {
8179
check_if(cx, expr)
8280
}
8381
}
@@ -108,7 +106,7 @@ fn check_collapsible_maybe_if_let(cx: &EarlyContext<'_>, else_: &ast::Expr) {
108106
if let ast::ExprKind::Block(ref block, _) = else_.node;
109107
if !block_starts_with_comment(cx, block);
110108
if let Some(else_) = expr_block(block);
111-
if !in_macro_or_desugar(else_.span);
109+
if !else_.span.from_expansion();
112110
if let ast::ExprKind::If(..) = else_.node;
113111
then {
114112
let mut applicability = Applicability::MachineApplicable;

clippy_lints/src/copies.rs

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

110108
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CopyAndPaste {
111109
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
112-
if !in_macro_or_desugar(expr.span) {
110+
if !expr.span.from_expansion() {
113111
// skip ifs directly in else, it will be checked in the parent if
114112
if let Some(expr) = get_parent_expr(cx, expr) {
115113
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_or_desugar, span_lint};
1+
use crate::utils::span_lint;
22
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
33
use rustc::{declare_lint_pass, declare_tool_lint};
44
use syntax::ast::*;
@@ -27,7 +27,7 @@ declare_lint_pass!(DoubleParens => [DOUBLE_PARENS]);
2727

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

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_or_desugar, is_present_in_source};
3+
use crate::utils::{camel_case, 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};
@@ -248,7 +248,7 @@ impl EarlyLintPass for EnumVariantNames {
248248
let item_name = item.ident.as_str();
249249
let item_name_chars = item_name.chars().count();
250250
let item_camel = to_camel_case(&item_name);
251-
if !in_macro_or_desugar(item.span) && is_present_in_source(cx, item.span) {
251+
if !item.span.from_expansion() && is_present_in_source(cx, item.span) {
252252
if let Some(&(ref mod_name, ref mod_camel)) = self.modules.last() {
253253
// constants don't have surrounding modules
254254
if !mod_camel.is_empty() {

clippy_lints/src/eq_op.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use crate::utils::{
2-
implements_trait, in_macro_or_desugar, is_copy, multispan_sugg, snippet, span_lint, span_lint_and_then, SpanlessEq,
3-
};
1+
use crate::utils::{implements_trait, is_copy, multispan_sugg, snippet, span_lint, span_lint_and_then, SpanlessEq};
42
use rustc::hir::*;
53
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
64
use rustc::{declare_lint_pass, declare_tool_lint};
@@ -52,7 +50,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
5250
#[allow(clippy::similar_names, clippy::too_many_lines)]
5351
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
5452
if let ExprKind::Binary(op, ref left, ref right) = e.node {
55-
if in_macro_or_desugar(e.span) {
53+
if e.span.from_expansion() {
5654
return;
5755
}
5856
if is_valid_operator(op) && SpanlessEq::new(cx).ignore_fn().eq_expr(left, right) {

0 commit comments

Comments
 (0)