Merge pull request #337 from Manishearth/indentfix

fix indentation
This commit is contained in:
llogiq 2015-09-17 07:44:39 +02:00
commit 862c195fa1
2 changed files with 31 additions and 31 deletions

View File

@ -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)
}
}
}

View File

@ -29,34 +29,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))