From 382b3f0601ea510e4cb4d0dd6c73310eb79708de Mon Sep 17 00:00:00 2001 From: Jason Newcomb Date: Wed, 23 Feb 2022 01:04:49 -0500 Subject: [PATCH] Fix counting the number of unchangeable arguments in `ptr_arg` --- clippy_lints/src/ptr.rs | 2 +- tests/ui/ptr_arg.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index e0ce1b7db003..2c328195f24e 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -547,7 +547,7 @@ fn check_ptr_arg_usage<'tcx>(cx: &LateContext<'tcx>, body: &'tcx Body<'_>, args: // Helper function to handle early returns. let mut set_skip_flag = || { - if result.skip { + if !result.skip { self.skip_count += 1; } result.skip = true; diff --git a/tests/ui/ptr_arg.rs b/tests/ui/ptr_arg.rs index 00b99da2631c..97990fedd51f 100644 --- a/tests/ui/ptr_arg.rs +++ b/tests/ui/ptr_arg.rs @@ -186,3 +186,11 @@ pub trait Trait { fn f(v: &mut Vec); fn f2(v: &mut Vec) {} } + +// Issue #8463 +fn two_vecs(a: &mut Vec, b: &mut Vec) { + a.push(0); + a.push(0); + a.push(0); + b.push(1); +}