if in_macro(cx, info) { return; }
if let ExprIf(ref check, ref then, None) = e.node {
- if let Some(&Expr{ node: ExprIf(ref check_inner, ref content, None), ..}) =
+ if let Some(&Expr{ node: ExprIf(ref check_inner, ref content, None), span: sp, ..}) =
single_stmt_of_block(then) {
+ if e.span.expn_id != sp.expn_id {
+ return;
+ }
+ cx.sess().note(&format!("{:?} -- {:?}", e.span, sp));
span_help_and_lint(cx, COLLAPSIBLE_IF, e.span,
"this if statement can be collapsed",
&format!("try\nif {} && {} {}",
/// Recover the essential nodes of a desugared for loop:
/// `for pat in arg { body }` becomes `(pat, arg, body)`.
-fn recover_for_loop<'a>(expr: &Expr) -> Option<(&Pat, &Expr, &Expr)> {
+fn recover_for_loop(expr: &Expr) -> Option<(&Pat, &Expr, &Expr)> {
if_let_chain! {
[
let ExprMatch(ref iterexpr, ref arms, _) = expr.node,
let ExprCall(_, ref iterargs) = iterexpr.node,
- iterargs.len() == 1,
- arms.len() == 1 && arms[0].guard.is_none(),
+ iterargs.len() == 1 && arms.len() == 1 && arms[0].guard.is_none(),
let ExprLoop(ref block, _) = arms[0].body.node,
block.stmts.is_empty(),
let Some(ref loopexpr) = block.expr,
}
fn check_fn(&mut self, cx: &Context, _: FnKind, decl: &FnDecl, _: &Block, _: Span, _: NodeId) {
- for ref arg in decl.inputs.iter() {
+ for ref arg in &decl.inputs {
if let PatIdent(BindByRef(_), _, _) = arg.pat.node {
span_lint(cx,
TOPLEVEL_REF_ARG,