mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-11 09:27:56 +00:00
fix indentation
This commit is contained in:
parent
68d4b3af12
commit
58fee220a9
@ -34,9 +34,9 @@ impl LintPass for CollapsibleIf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn check_expr(&mut self, cx: &Context, expr: &Expr) {
|
fn check_expr(&mut self, cx: &Context, expr: &Expr) {
|
||||||
if !in_macro(cx, expr.span) {
|
if !in_macro(cx, expr.span) {
|
||||||
check_if(cx, expr)
|
check_if(cx, expr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
56
src/utils.rs
56
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
|
/// returns true if the macro that expanded the crate was outside of
|
||||||
/// the current crate or was a compiler plugin
|
/// the current crate or was a compiler plugin
|
||||||
pub fn in_external_macro(cx: &Context, span: Span) -> bool {
|
pub fn in_external_macro(cx: &Context, span: Span) -> bool {
|
||||||
/// invokes in_macro with the expansion info of the given span
|
/// invokes in_macro with the expansion info of the given span
|
||||||
/// slightly heavy, try to use this after other checks have already happened
|
/// slightly heavy, try to use this after other checks have already happened
|
||||||
fn in_macro_ext(cx: &Context, opt_info: Option<&ExpnInfo>) -> bool {
|
fn in_macro_ext(cx: &Context, opt_info: Option<&ExpnInfo>) -> bool {
|
||||||
// no ExpnInfo = no macro
|
// no ExpnInfo = no macro
|
||||||
opt_info.map_or(false, |info| {
|
opt_info.map_or(false, |info| {
|
||||||
match info.callee.format {
|
match info.callee.format {
|
||||||
ExpnFormat::CompilerExpansion(..) => {
|
ExpnFormat::CompilerExpansion(..) => {
|
||||||
if info.callee.name() == "closure expansion" {
|
if info.callee.name() == "closure expansion" {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ExpnFormat::MacroAttribute(..) => {
|
ExpnFormat::MacroAttribute(..) => {
|
||||||
// these are all plugins
|
// these are all plugins
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
// no span for the callee = external macro
|
// no span for the callee = external macro
|
||||||
info.callee.span.map_or(true, |span| {
|
info.callee.span.map_or(true, |span| {
|
||||||
// no snippet = external macro or compiler-builtin expansion
|
// no snippet = external macro or compiler-builtin expansion
|
||||||
cx.sess().codemap().span_to_snippet(span).ok().map_or(true, |code|
|
cx.sess().codemap().span_to_snippet(span).ok().map_or(true, |code|
|
||||||
// macro doesn't start with "macro_rules"
|
// macro doesn't start with "macro_rules"
|
||||||
// = compiler plugin
|
// = compiler plugin
|
||||||
!code.starts_with("macro_rules")
|
!code.starts_with("macro_rules")
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
cx.sess().codemap().with_expn_info(span.expn_id,
|
cx.sess().codemap().with_expn_info(span.expn_id,
|
||||||
|info| in_macro_ext(cx, info))
|
|info| in_macro_ext(cx, info))
|
||||||
|
Loading…
Reference in New Issue
Block a user