From 58fee220a9ec3bd904aa7c8e84b6643b51e88f76 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Thu, 17 Sep 2015 07:27:18 +0200 Subject: [PATCH] fix indentation --- src/collapsible_if.rs | 6 ++--- src/utils.rs | 56 +++++++++++++++++++++---------------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/collapsible_if.rs b/src/collapsible_if.rs index 7326bd20c7c..d22fc4817f3 100644 --- a/src/collapsible_if.rs +++ b/src/collapsible_if.rs @@ -34,9 +34,9 @@ impl LintPass for CollapsibleIf { } fn check_expr(&mut self, cx: &Context, expr: &Expr) { - if !in_macro(cx, expr.span) { - check_if(cx, expr) - } + if !in_macro(cx, expr.span) { + check_if(cx, expr) + } } } diff --git a/src/utils.rs b/src/utils.rs index 01c9adf866c..a49a7b2b7a3 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -28,34 +28,34 @@ pub fn in_macro(cx: &Context, span: Span) -> bool { /// returns true if the macro that expanded the crate was outside of /// the current crate or was a compiler plugin pub fn in_external_macro(cx: &Context, span: Span) -> bool { - /// invokes in_macro with the expansion info of the given span - /// slightly heavy, try to use this after other checks have already happened - fn in_macro_ext(cx: &Context, opt_info: Option<&ExpnInfo>) -> bool { - // no ExpnInfo = no macro - opt_info.map_or(false, |info| { - match info.callee.format { - ExpnFormat::CompilerExpansion(..) => { - if info.callee.name() == "closure expansion" { - return false; - } - }, - ExpnFormat::MacroAttribute(..) => { - // these are all plugins - return true; - }, - _ => (), - } - // no span for the callee = external macro - info.callee.span.map_or(true, |span| { - // no snippet = external macro or compiler-builtin expansion - cx.sess().codemap().span_to_snippet(span).ok().map_or(true, |code| - // macro doesn't start with "macro_rules" - // = compiler plugin - !code.starts_with("macro_rules") - ) - }) - }) - } + /// invokes in_macro with the expansion info of the given span + /// slightly heavy, try to use this after other checks have already happened + fn in_macro_ext(cx: &Context, opt_info: Option<&ExpnInfo>) -> bool { + // no ExpnInfo = no macro + opt_info.map_or(false, |info| { + match info.callee.format { + ExpnFormat::CompilerExpansion(..) => { + if info.callee.name() == "closure expansion" { + return false; + } + }, + ExpnFormat::MacroAttribute(..) => { + // these are all plugins + return true; + }, + _ => (), + } + // no span for the callee = external macro + info.callee.span.map_or(true, |span| { + // no snippet = external macro or compiler-builtin expansion + cx.sess().codemap().span_to_snippet(span).ok().map_or(true, |code| + // macro doesn't start with "macro_rules" + // = compiler plugin + !code.starts_with("macro_rules") + ) + }) + }) + } cx.sess().codemap().with_expn_info(span.expn_id, |info| in_macro_ext(cx, info))