From 7a4f7c335b1e917849c4f3f94a4f0acb683cfa00 Mon Sep 17 00:00:00 2001 From: Enrico Schmitz Date: Sat, 1 Apr 2017 00:14:04 +0200 Subject: [PATCH] Remove unused cs parameter for is_macro and friends --- clippy_lints/src/attrs.rs | 2 +- clippy_lints/src/block_in_if_condition.rs | 4 ++-- clippy_lints/src/booleans.rs | 4 ++-- clippy_lints/src/collapsible_if.rs | 4 ++-- clippy_lints/src/copies.rs | 2 +- clippy_lints/src/cyclomatic_complexity.rs | 2 +- clippy_lints/src/enum_variants.rs | 2 +- clippy_lints/src/format.rs | 2 +- clippy_lints/src/formatting.rs | 6 +++--- clippy_lints/src/identity_op.rs | 2 +- clippy_lints/src/items_after_statements.rs | 4 ++-- clippy_lints/src/len_zero.rs | 4 ++-- clippy_lints/src/matches.rs | 8 ++++---- clippy_lints/src/methods.rs | 2 +- clippy_lints/src/misc.rs | 6 +++--- clippy_lints/src/missing_doc.rs | 2 +- clippy_lints/src/needless_borrow.rs | 4 ++-- clippy_lints/src/needless_pass_by_value.rs | 2 +- clippy_lints/src/no_effect.rs | 6 +++--- clippy_lints/src/non_expressive_names.rs | 2 +- clippy_lints/src/panic.rs | 2 +- clippy_lints/src/print.rs | 6 +++--- clippy_lints/src/regex.rs | 2 +- clippy_lints/src/should_assert_eq.rs | 2 +- clippy_lints/src/strings.rs | 2 +- clippy_lints/src/types.rs | 12 ++++++------ clippy_lints/src/unused_label.rs | 2 +- clippy_lints/src/utils/higher.rs | 2 +- clippy_lints/src/utils/mod.rs | 6 +++--- 29 files changed, 53 insertions(+), 53 deletions(-) diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 646bcdad5ff..1c4ac3c6261 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -215,7 +215,7 @@ fn is_relevant_expr(tcx: ty::TyCtxt, tables: &ty::TypeckTables, expr: &Expr) -> } fn check_attrs(cx: &LateContext, span: Span, name: &Name, attrs: &[Attribute]) { - if in_macro(cx, span) { + if in_macro(span) { return; } diff --git a/clippy_lints/src/block_in_if_condition.rs b/clippy_lints/src/block_in_if_condition.rs index f41d29c569d..cabffa8e969 100644 --- a/clippy_lints/src/block_in_if_condition.rs +++ b/clippy_lints/src/block_in_if_condition.rs @@ -84,7 +84,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlockInIfCondition { if let Some(ref ex) = block.expr { // don't dig into the expression here, just suggest that they remove // the block - if in_macro(cx, expr.span) || differing_macro_contexts(expr.span, ex.span) { + if in_macro(expr.span) || differing_macro_contexts(expr.span, ex.span) { return; } span_help_and_lint(cx, @@ -97,7 +97,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlockInIfCondition { } } else { let span = block.expr.as_ref().map_or_else(|| block.stmts[0].span, |e| e.span); - if in_macro(cx, span) || differing_macro_contexts(expr.span, span) { + if in_macro(span) || differing_macro_contexts(expr.span, span) { return; } // move block higher diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index 7ab3af17f4b..fd357feab6b 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -93,7 +93,7 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> { fn run(&mut self, e: &'v Expr) -> Result { // prevent folding of `cfg!` macros and the like - if !in_macro(self.cx, e.span) { + if !in_macro(e.span) { match e.node { ExprUnary(UnNot, ref inner) => return Ok(Bool::Not(box self.run(inner)?)), ExprBinary(binop, ref lhs, ref rhs) => { @@ -394,7 +394,7 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> { fn visit_expr(&mut self, e: &'tcx Expr) { - if in_macro(self.cx, e.span) { + if in_macro(e.span) { return; } match e.node { diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs index 33aaf5fcb0a..239a24b6b3c 100644 --- a/clippy_lints/src/collapsible_if.rs +++ b/clippy_lints/src/collapsible_if.rs @@ -78,7 +78,7 @@ impl LintPass for CollapsibleIf { impl EarlyLintPass for CollapsibleIf { fn check_expr(&mut self, cx: &EarlyContext, expr: &ast::Expr) { - if !in_macro(cx, expr.span) { + if !in_macro(expr.span) { check_if(cx, expr) } } @@ -104,7 +104,7 @@ fn check_collapsible_maybe_if_let(cx: &EarlyContext, else_: &ast::Expr) { if_let_chain! {[ let ast::ExprKind::Block(ref block) = else_.node, let Some(ref else_) = expr_block(block), - !in_macro(cx, else_.span), + !in_macro(else_.span), ], { match else_.node { ast::ExprKind::If(..) | ast::ExprKind::IfLet(..) => { diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index 92d0445a4ce..730c0ac9633 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -111,7 +111,7 @@ impl LintPass for CopyAndPaste { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CopyAndPaste { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { - if !in_macro(cx, expr.span) { + if !in_macro(expr.span) { // skip ifs directly in else, it will be checked in the parent if if let Some(&Expr { node: ExprIf(_, _, Some(ref else_expr)), .. }) = get_parent_expr(cx, expr) { if else_expr.id == expr.id { diff --git a/clippy_lints/src/cyclomatic_complexity.rs b/clippy_lints/src/cyclomatic_complexity.rs index 03882a0acf5..ed836af4403 100644 --- a/clippy_lints/src/cyclomatic_complexity.rs +++ b/clippy_lints/src/cyclomatic_complexity.rs @@ -42,7 +42,7 @@ impl LintPass for CyclomaticComplexity { impl CyclomaticComplexity { fn check<'a, 'tcx: 'a>(&mut self, cx: &'a LateContext<'a, 'tcx>, body: &'tcx Body, span: Span) { - if in_macro(cx, span) { + if in_macro(span) { return; } diff --git a/clippy_lints/src/enum_variants.rs b/clippy_lints/src/enum_variants.rs index d0c75125df0..16a2e021723 100644 --- a/clippy_lints/src/enum_variants.rs +++ b/clippy_lints/src/enum_variants.rs @@ -228,7 +228,7 @@ impl EarlyLintPass for EnumVariantNames { let item_name = item.ident.name.as_str(); let item_name_chars = item_name.chars().count(); let item_camel = to_camel_case(&item_name); - if !in_macro(cx, item.span) { + if !in_macro(item.span) { if let Some(&(ref mod_name, ref mod_camel)) = self.modules.last() { // constants don't have surrounding modules if !mod_camel.is_empty() { diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index 32e02e30b79..bcbb8b1cccd 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -40,7 +40,7 @@ impl LintPass for Pass { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { - if let Some(span) = is_expn_of(cx, expr.span, "format") { + if let Some(span) = is_expn_of(expr.span, "format") { match expr.node { // `format!("{}", foo)` expansion ExprCall(ref fun, ref args) => { diff --git a/clippy_lints/src/formatting.rs b/clippy_lints/src/formatting.rs index 8b5c35d0996..7fa8c3deb99 100644 --- a/clippy_lints/src/formatting.rs +++ b/clippy_lints/src/formatting.rs @@ -99,7 +99,7 @@ impl EarlyLintPass for Formatting { /// Implementation of the `SUSPICIOUS_ASSIGNMENT_FORMATTING` lint. fn check_assign(cx: &EarlyContext, expr: &ast::Expr) { if let ast::ExprKind::Assign(ref lhs, ref rhs) = expr.node { - if !differing_macro_contexts(lhs.span, rhs.span) && !in_macro(cx, lhs.span) { + if !differing_macro_contexts(lhs.span, rhs.span) && !in_macro(lhs.span) { let eq_span = Span { lo: lhs.span.hi, hi: rhs.span.lo, ctxt: NO_EXPANSION }; if let ast::ExprKind::Unary(op, ref sub_rhs) = rhs.node { if let Some(eq_snippet) = snippet_opt(cx, eq_span) { @@ -124,7 +124,7 @@ fn check_assign(cx: &EarlyContext, expr: &ast::Expr) { /// Implementation of the `SUSPICIOUS_ELSE_FORMATTING` lint for weird `else if`. fn check_else_if(cx: &EarlyContext, expr: &ast::Expr) { if let Some((then, &Some(ref else_))) = unsugar_if(expr) { - if unsugar_if(else_).is_some() && !differing_macro_contexts(then.span, else_.span) && !in_macro(cx, then.span) { + if unsugar_if(else_).is_some() && !differing_macro_contexts(then.span, else_.span) && !in_macro(then.span) { // this will be a span from the closing ‘}’ of the “then” block (excluding) to the // “if” of the “else if” block (excluding) let else_span = Span { lo: then.span.hi, hi: else_.span.lo, ctxt: NO_EXPANSION }; @@ -174,7 +174,7 @@ fn check_array(cx: &EarlyContext, expr: &ast::Expr) { /// Implementation of the `SUSPICIOUS_ELSE_FORMATTING` lint for consecutive ifs. fn check_consecutive_ifs(cx: &EarlyContext, first: &ast::Expr, second: &ast::Expr) { - if !differing_macro_contexts(first.span, second.span) && !in_macro(cx, first.span) && + if !differing_macro_contexts(first.span, second.span) && !in_macro(first.span) && unsugar_if(first).is_some() && unsugar_if(second).is_some() { // where the else would be let else_span = Span { lo: first.span.hi, hi: second.span.lo, ctxt: NO_EXPANSION }; diff --git a/clippy_lints/src/identity_op.rs b/clippy_lints/src/identity_op.rs index 82db13b1025..e57feaa5937 100644 --- a/clippy_lints/src/identity_op.rs +++ b/clippy_lints/src/identity_op.rs @@ -33,7 +33,7 @@ impl LintPass for IdentityOp { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityOp { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { - if in_macro(cx, e.span) { + if in_macro(e.span) { return; } if let ExprBinary(ref cmp, ref left, ref right) = e.node { diff --git a/clippy_lints/src/items_after_statements.rs b/clippy_lints/src/items_after_statements.rs index 5789f6a5f80..b3561720cc7 100644 --- a/clippy_lints/src/items_after_statements.rs +++ b/clippy_lints/src/items_after_statements.rs @@ -42,7 +42,7 @@ impl LintPass for ItemsAfterStatements { impl EarlyLintPass for ItemsAfterStatements { fn check_block(&mut self, cx: &EarlyContext, item: &Block) { - if in_macro(cx, item.span) { + if in_macro(item.span) { return; } @@ -55,7 +55,7 @@ impl EarlyLintPass for ItemsAfterStatements { // lint on all further items for stmt in stmts { if let StmtKind::Item(ref it) = *stmt { - if in_macro(cx, it.span) { + if in_macro(it.span) { return; } if let ItemKind::MacroDef(..) = it.node { diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index 3c7b139cbd7..92fa1324324 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -61,7 +61,7 @@ impl LintPass for LenZero { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LenZero { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { - if in_macro(cx, item.span) { + if in_macro(item.span) { return; } @@ -73,7 +73,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LenZero { } fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { - if in_macro(cx, expr.span) { + if in_macro(expr.span) { return; } diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index 46dd5464881..f8f50bfb853 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -342,7 +342,7 @@ fn check_wild_err_arm(cx: &LateContext, ex: &Expr, arms: &[Arm]) { path_str == "Err", inner.iter().any(|pat| pat.node == PatKind::Wild), let ExprBlock(ref block) = arm.body.node, - is_panic_block(cx, block) + is_panic_block(block) ], { // `Err(_)` arm with `panic!` found span_note_and_lint(cx, @@ -359,13 +359,13 @@ fn check_wild_err_arm(cx: &LateContext, ex: &Expr, arms: &[Arm]) { } // If the block contains only a `panic!` macro (as expression or statement) -fn is_panic_block(cx: &LateContext, block: &Block) -> bool { +fn is_panic_block(block: &Block) -> bool { match (&block.expr, block.stmts.len(), block.stmts.first()) { (&Some(ref exp), 0, _) => { - is_expn_of(cx, exp.span, "panic").is_some() && is_expn_of(cx, exp.span, "unreachable").is_none() + is_expn_of(exp.span, "panic").is_some() && is_expn_of(exp.span, "unreachable").is_none() }, (&None, 1, Some(stmt)) => { - is_expn_of(cx, stmt.span, "panic").is_some() && is_expn_of(cx, stmt.span, "unreachable").is_none() + is_expn_of(stmt.span, "panic").is_some() && is_expn_of(stmt.span, "unreachable").is_none() }, _ => false, } diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index c54755a4332..bc4c2b037e9 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -554,7 +554,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { // ^ required because `cyclomatic_complexity` attribute shows up as unused #[cyclomatic_complexity = "30"] fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) { - if in_macro(cx, expr.span) { + if in_macro(expr.span) { return; } diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 001bb3f4261..5d3f07ecba9 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -326,7 +326,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { }, _ => {}, } - if in_attributes_expansion(cx, expr) { + if in_attributes_expansion(expr) { // Don't lint things expanded by #[derive(...)], etc return; } @@ -498,7 +498,7 @@ fn is_used(cx: &LateContext, expr: &Expr) -> bool { /// Test whether an expression is in a macro expansion (e.g. something generated by /// `#[derive(...)`] or the like). -fn in_attributes_expansion(cx: &LateContext, expr: &Expr) -> bool { +fn in_attributes_expansion(expr: &Expr) -> bool { expr.span.ctxt.outer().expn_info().map(|info| { matches!(info.callee.format, ExpnFormat::MacroAttribute(_)) }).unwrap_or(false) @@ -510,7 +510,7 @@ fn non_macro_local(cx: &LateContext, def: &def::Def) -> bool { def::Def::Local(id) | def::Def::Upvar(id, _, _) => { if let Some(span) = cx.tcx.hir.span_if_local(id) { - !in_macro(cx, span) + !in_macro(span) } else { true } diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index 75cc588119f..1249b638a08 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -73,7 +73,7 @@ impl MissingDoc { return; } - if in_macro(cx, sp) { + if in_macro(sp) { return; } diff --git a/clippy_lints/src/needless_borrow.rs b/clippy_lints/src/needless_borrow.rs index 8071f2903a9..740dd2bcb3f 100644 --- a/clippy_lints/src/needless_borrow.rs +++ b/clippy_lints/src/needless_borrow.rs @@ -36,7 +36,7 @@ impl LintPass for NeedlessBorrow { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { - if in_macro(cx, e.span) { + if in_macro(e.span) { return; } if let ExprAddrOf(MutImmutable, ref inner) = e.node { @@ -55,7 +55,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow { } } fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) { - if in_macro(cx, pat.span) { + if in_macro(pat.span) { return; } if_let_chain! {[ diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index ed495e7e567..28129484a37 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -55,7 +55,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { span: Span, node_id: NodeId ) { - if in_macro(cx, span) { + if in_macro(span) { return; } diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs index f53fcb60706..4796243770c 100644 --- a/clippy_lints/src/no_effect.rs +++ b/clippy_lints/src/no_effect.rs @@ -41,7 +41,7 @@ declare_lint! { } fn has_no_effect(cx: &LateContext, expr: &Expr) -> bool { - if in_macro(cx, expr.span) { + if in_macro(expr.span) { return false; } match expr.node { @@ -110,7 +110,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { } else if let Some(reduced) = reduce_expression(cx, expr) { let mut snippet = String::new(); for e in reduced { - if in_macro(cx, e.span) { + if in_macro(e.span) { return; } if let Some(snip) = snippet_opt(cx, e.span) { @@ -132,7 +132,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { fn reduce_expression<'a>(cx: &LateContext, expr: &'a Expr) -> Option> { - if in_macro(cx, expr.span) { + if in_macro(expr.span) { return None; } match expr.node { diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index a195673a53b..67f1aaa27ab 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -135,7 +135,7 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> { } } fn check_name(&mut self, span: Span, name: Name) { - if in_macro(self.0.cx, span) { + if in_macro(span) { return; } let interned_name = name.as_str(); diff --git a/clippy_lints/src/panic.rs b/clippy_lints/src/panic.rs index 1e97d44ff7d..8db7de30f7c 100644 --- a/clippy_lints/src/panic.rs +++ b/clippy_lints/src/panic.rs @@ -42,7 +42,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { let ExprPath(ref qpath) = fun.node, match_def_path(cx.tcx, resolve_node(cx, qpath, fun.id).def_id(), &paths::BEGIN_PANIC), let ExprLit(ref lit) = params[0].node, - is_direct_expn_of(cx, params[0].span, "panic").is_some(), + is_direct_expn_of(params[0].span, "panic").is_some(), let LitKind::Str(ref string, _) = lit.node, let Some(par) = string.as_str().find('{'), string.as_str()[par..].contains('}') diff --git a/clippy_lints/src/print.rs b/clippy_lints/src/print.rs index 0776b660b41..a6eb5c5dfda 100644 --- a/clippy_lints/src/print.rs +++ b/clippy_lints/src/print.rs @@ -77,9 +77,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { // Search for `std::io::_print(..)` which is unique in a // `print!` expansion. if match_def_path(cx.tcx, fun_id, &paths::IO_PRINT) { - if let Some(span) = is_expn_of(cx, expr.span, "print") { + if let Some(span) = is_expn_of(expr.span, "print") { // `println!` uses `print!`. - let (span, name) = match is_expn_of(cx, span, "println") { + let (span, name) = match is_expn_of(span, "println") { Some(span) => (span, "println"), None => (span, "print"), }; @@ -125,7 +125,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { if let ExprPath(ref qpath) = args[1].node { let def_id = cx.tables.qpath_def(qpath, args[1].id).def_id(); if match_def_path(cx.tcx, def_id, &paths::DEBUG_FMT_METHOD) && !is_in_debug_impl(cx, expr) && - is_expn_of(cx, expr.span, "panic").is_none() { + is_expn_of(expr.span, "panic").is_none() { span_lint(cx, USE_DEBUG, args[0].span, "use of `Debug`-based formatting"); } } diff --git a/clippy_lints/src/regex.rs b/clippy_lints/src/regex.rs index 2808dfd3546..cdaf51d6646 100644 --- a/clippy_lints/src/regex.rs +++ b/clippy_lints/src/regex.rs @@ -91,7 +91,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { self.last.is_none(), let Some(ref expr) = block.expr, match_type(cx, cx.tables.expr_ty(expr), &paths::REGEX), - let Some(span) = is_expn_of(cx, expr.span, "regex"), + let Some(span) = is_expn_of(expr.span, "regex"), ], { if !self.spans.contains(&span) { span_lint(cx, diff --git a/clippy_lints/src/should_assert_eq.rs b/clippy_lints/src/should_assert_eq.rs index 372ee210336..59532f3d440 100644 --- a/clippy_lints/src/should_assert_eq.rs +++ b/clippy_lints/src/should_assert_eq.rs @@ -36,7 +36,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ShouldAssertEq { let ExprIf(ref cond, ..) = e.node, let ExprUnary(UnOp::UnNot, ref cond) = cond.node, let ExprBinary(ref binop, ref expr1, ref expr2) = cond.node, - is_direct_expn_of(cx, e.span, "assert").is_some(), + is_direct_expn_of(e.span, "assert").is_some(), let Some(debug_trait) = cx.tcx.lang_items.debug_trait(), ], { let sugg = match binop.node { diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs index 0e4bf017f3f..646ba598f81 100644 --- a/clippy_lints/src/strings.rs +++ b/clippy_lints/src/strings.rs @@ -146,7 +146,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StringLitAsBytes { if name.node == "as_bytes" { if let ExprLit(ref lit) = args[0].node { if let LitKind::Str(ref lit_content, _) = lit.node { - if lit_content.as_str().chars().all(|c| c.is_ascii()) && !in_macro(cx, args[0].span) { + if lit_content.as_str().chars().all(|c| c.is_ascii()) && !in_macro(args[0].span) { span_lint_and_then(cx, STRING_LIT_AS_BYTES, e.span, diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 7ec69314621..de90ff323d9 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -107,7 +107,7 @@ fn check_fn_decl(cx: &LateContext, decl: &FnDecl) { } fn check_ty(cx: &LateContext, ast_ty: &Ty) { - if in_macro(cx, ast_ty.span) { + if in_macro(ast_ty.span) { return; } match ast_ty.node { @@ -199,7 +199,7 @@ fn check_let_unit(cx: &LateContext, decl: &Decl) { let bindtype = &cx.tables.pat_ty(&local.pat).sty; match *bindtype { ty::TyTuple(slice, _) if slice.is_empty() => { - if in_external_macro(cx, decl.span) || in_macro(cx, local.pat.span) { + if in_external_macro(cx, decl.span) || in_macro(local.pat.span) { return; } if higher::is_from_for_desugar(decl) { @@ -261,7 +261,7 @@ impl LintPass for UnitCmp { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnitCmp { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { - if in_macro(cx, expr.span) { + if in_macro(expr.span) { return; } if let ExprBinary(ref cmp, ref left, _) = expr.node { @@ -694,7 +694,7 @@ impl<'a, 'tcx> TypeComplexityPass { } fn check_type(&self, cx: &LateContext<'a, 'tcx>, ty: &'tcx Ty) { - if in_macro(cx, ty.span) { + if in_macro(ty.span) { return; } let score = { @@ -797,7 +797,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CharLitAsU8 { if let ExprCast(ref e, _) = expr.node { if let ExprLit(ref l) = e.node { if let LitKind::Char(_) = l.node { - if ty::TyUint(UintTy::U8) == cx.tables.expr_ty(expr).sty && !in_macro(cx, expr.span) { + if ty::TyUint(UintTy::U8) == cx.tables.expr_ty(expr).sty && !in_macro(expr.span) { let msg = "casting character literal to u8. `char`s \ are 4 bytes wide in rust, so casting to u8 \ truncates them"; @@ -971,7 +971,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AbsurdExtremeComparisons { if let ExprBinary(ref cmp, ref lhs, ref rhs) = expr.node { if let Some((culprit, result)) = detect_absurd_comparison(cx, cmp.node, lhs, rhs) { - if !in_macro(cx, expr.span) { + if !in_macro(expr.span) { let msg = "this comparison involving the minimum or maximum element for this \ type contains a case that is always true or always false"; diff --git a/clippy_lints/src/unused_label.rs b/clippy_lints/src/unused_label.rs index e004b80323e..15f327fb5c2 100644 --- a/clippy_lints/src/unused_label.rs +++ b/clippy_lints/src/unused_label.rs @@ -50,7 +50,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedLabel { span: Span, fn_id: ast::NodeId ) { - if in_macro(cx, span) { + if in_macro(span) { return; } diff --git a/clippy_lints/src/utils/higher.rs b/clippy_lints/src/utils/higher.rs index 1358e1f28f2..10a1c18e182 100644 --- a/clippy_lints/src/utils/higher.rs +++ b/clippy_lints/src/utils/higher.rs @@ -156,7 +156,7 @@ pub fn vec_macro<'e>(cx: &LateContext, expr: &'e hir::Expr) -> Option bool { } /// Returns true if this `expn_info` was expanded by any macro. -pub fn in_macro<'a, T: LintContext<'a>>(cx: &T, span: Span) -> bool { +pub fn in_macro(span: Span) -> bool { span.ctxt.outer().expn_info().map(|info| { match info.callee.format {// don't treat range expressions desugared to structs as "in_macro" ExpnFormat::CompilerDesugaring(name) => name != "...", @@ -685,7 +685,7 @@ fn parse_attrs(sess: &Session, attrs: &[ast::Attribute], name: &' /// Return the pre-expansion span if is this comes from an expansion of the macro `name`. /// See also `is_direct_expn_of`. -pub fn is_expn_of(cx: &LateContext, mut span: Span, name: &str) -> Option { +pub fn is_expn_of(mut span: Span, name: &str) -> Option { loop { let span_name_span = span.ctxt.outer() .expn_info().map(|ei| (ei.callee.name(), ei.call_site)); @@ -705,7 +705,7 @@ pub fn is_expn_of(cx: &LateContext, mut span: Span, name: &str) -> Option /// ``` /// `42` is considered expanded from `foo!` and `bar!` by `is_expn_of` but only `bar!` by /// `is_direct_expn_of`. -pub fn is_direct_expn_of(cx: &LateContext, span: Span, name: &str) -> Option { +pub fn is_direct_expn_of(span: Span, name: &str) -> Option { let span_name_span = span.ctxt.outer() .expn_info().map(|ei| (ei.callee.name(), ei.call_site));