Skip to content

Commit

Permalink
Formatting inside if_chain! macro
Browse files Browse the repository at this point in the history
  • Loading branch information
flip1995 committed May 21, 2019
1 parent f32c2fc commit 42d849c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions clippy_lints/src/get_last_with_len.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for GetLastWithLen {

// Argument to "get" is a subtraction
if let Some(get_index_arg) = args.get(1);
if let ExprKind::Binary(Spanned{node: BinOpKind::Sub, ..},
lhs, rhs) = &get_index_arg.node;
if let ExprKind::Binary(
Spanned {
node: BinOpKind::Sub,
..
},
lhs,
rhs,
) = &get_index_arg.node;

// LHS of subtraction is "x.len()"
if let ExprKind::MethodCall(arg_lhs_path, _, lhs_args) = &lhs.node;
Expand Down Expand Up @@ -91,7 +97,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for GetLastWithLen {
&format!("accessing last element with `{0}.get({0}.len() - 1)`", vec_name),
"try",
format!("{}.last()", vec_name),
applicability);
applicability,
);
}
}
}
Expand Down

0 comments on commit 42d849c

Please sign in to comment.