Formatting inside if_chain! macro

This commit is contained in:
Philipp Krones 2019-05-21 09:33:59 +02:00 committed by flip1995
parent f32c2fcb7e
commit 42d849c185
No known key found for this signature in database
GPG key ID: 01C836B640FFDFB1

View file

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