Skip to content

Commit 80dec53

Browse files
committed
Add SpanlessEq to test equality of Vecs
1 parent d73918b commit 80dec53

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

clippy_lints/src/use_last.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! lint on using `x.get(x.len() - 1)` instead of `x.last()`
22
3-
use crate::utils::{match_type, paths, span_lint_and_sugg, snippet_with_applicability};
3+
use crate::utils::{match_type, paths, span_lint_and_sugg,
4+
snippet_with_applicability, SpanlessEq};
45
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
56
use rustc::{declare_tool_lint, lint_array};
67
use rustc::hir::{Expr, ExprKind};
@@ -89,11 +90,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseLast {
8990
if let Some(arg_lhs_struct) = lhs_args.get(0);
9091
// let _ = println!("LHS of sub method has an arg");
9192

92-
// TODO: Is this a valid way to check if they reference the same vector?
93-
// if let ExprKind::Path(arg_lhs_struct_path) = arg_lhs_struct.node;
94-
// if let ExprKind::Path(struct_calling_on_path) = struct_calling_on.nod
95-
// if arg_lhs_struct_path == struct_calling_on_path;
96-
// let _ = println!("The vector in .get and .len were the same");
93+
if SpanlessEq::new(cx).eq_expr(struct_calling_on, arg_lhs_struct);
9794

9895
// RHS of subtraction is 1
9996
if let ExprKind::Lit(ref rhs_lit) = rhs.node;

0 commit comments

Comments
 (0)