Skip to content

Commit aef5fe2

Browse files
committed
Make some fixes
1 parent 422ba88 commit aef5fe2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

clippy_lints/src/use_last.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ impl LintPass for UseLast {
5050
}
5151
}
5252

53-
impl LateLintPass for UseLast {
54-
fn check_expr(&mut self, cx: &LateContext<'_>, mut item: &Expr) {
53+
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseLast {
54+
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
5555
if_chain! {
5656
if let StmtKind::Local(ref local) = stmt.node;
5757
if let Some(ref init) = local.init
@@ -60,7 +60,12 @@ impl LateLintPass for UseLast {
6060
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local.pat.node;
6161
if name.node.as_str() == "last_element";
6262
then {
63-
// report your lint here
63+
span_lint(cx,
64+
USE_LAST,
65+
expr.span,
66+
// Todo: fix this
67+
&format!("It is more idiomatic to use {}.iter().enumerate()",
68+
snippet(cx, iter_args[0].span, "_")));
6469
}
6570
}
6671

0 commit comments

Comments
 (0)