Skip to content

Commit 5657dfb

Browse files
committed
Try to tell if two vectors are the same
1 parent c382c8b commit 5657dfb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

clippy_lints/src/use_last.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseLast {
8686
// let _ = println!("LHS of sub is a method call");
8787
if arg_lhs_path.ident.name == "len";
8888
// let _ = println!("LHS of sub was method named len");
89-
if let Some(_arg_lhs_struct) = lhs_args.get(0);
89+
if let Some(arg_lhs_struct) = lhs_args.get(0);
9090
// let _ = println!("LHS of sub method has an arg");
9191

9292
// TODO: Is this a valid way to check if they reference the same vector?
93-
// if arg_lhs_struct.hir_id == struct_calling_on.hir_id;
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;
9496
// let _ = println!("The vector in .get and .len were the same");
9597

9698
// RHS of subtraction is 1

0 commit comments

Comments
 (0)