about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJason Newcomb <jsnewcomb@pm.me>2022-02-23 01:04:49 -0500
committerJason Newcomb <jsnewcomb@pm.me>2022-02-23 01:04:49 -0500
commit382b3f0601ea510e4cb4d0dd6c73310eb79708de (patch)
treefb05b927db911812a52c950161cfdd2c5c6483d9
parent7f8760a44ce9b1424f6f1519ed452d6b323bc275 (diff)
downloadrust-382b3f0601ea510e4cb4d0dd6c73310eb79708de.tar.gz
rust-382b3f0601ea510e4cb4d0dd6c73310eb79708de.zip
Fix counting the number of unchangeable arguments in `ptr_arg`
-rw-r--r--clippy_lints/src/ptr.rs2
-rw-r--r--tests/ui/ptr_arg.rs8
2 files changed, 9 insertions, 1 deletions
diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs
index e0ce1b7db00..2c328195f24 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 00b99da2631..97990fedd51 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<i32>);
     fn f2(v: &mut Vec<i32>) {}
 }
+
+// Issue #8463
+fn two_vecs(a: &mut Vec<u32>, b: &mut Vec<u32>) {
+    a.push(0);
+    a.push(0);
+    a.push(0);
+    b.push(1);
+}