about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Macleod <alex@macleod.io>2025-04-13 13:54:25 +0000
committerGitHub <noreply@github.com>2025-04-13 13:54:25 +0000
commitdbc07558ef60859f91511eef39f3430c32f80ff7 (patch)
treeb040656029a267f9068fb70b4b9cb6bd8bfa9464
parentd19c651c627a69db728c76a7647853a44b28160c (diff)
parentaa2f48b09ddc4a3ed50005cefab9cdd26c9cd8bb (diff)
downloadrust-dbc07558ef60859f91511eef39f3430c32f80ff7.tar.gz
rust-dbc07558ef60859f91511eef39f3430c32f80ff7.zip
Change Test for Issue 14422 (Cognitive Complexity lowered through mul… (#14603)
changelog: [cognitive_complexity]: Changed Test for this issue from
making sure its not a false positive to making sure its not a false
negative which was the original issue at hand. The test as it was would
also not fail without the change introduced. This test will show if any
regression is made in further pushes.

adds tests to https://github.com/rust-lang/rust-clippy/issues/14422
-rw-r--r--tests/ui/cognitive_complexity.rs4
-rw-r--r--tests/ui/cognitive_complexity.stderr18
2 files changed, 20 insertions, 2 deletions
diff --git a/tests/ui/cognitive_complexity.rs b/tests/ui/cognitive_complexity.rs
index 4f6dd35e8cb..8080c6775e0 100644
--- a/tests/ui/cognitive_complexity.rs
+++ b/tests/ui/cognitive_complexity.rs
@@ -454,15 +454,17 @@ mod issue9300 {
     }
 }
 
-#[clippy::cognitive_complexity = "2"]
+#[clippy::cognitive_complexity = "1"]
 mod issue14422 {
     fn foo() {
+        //~^ cognitive_complexity
         for _ in 0..10 {
             println!("hello there");
         }
     }
 
     fn bar() {
+        //~^ cognitive_complexity
         for _ in 0..10 {
             println!("hello there");
         }
diff --git a/tests/ui/cognitive_complexity.stderr b/tests/ui/cognitive_complexity.stderr
index 2be56ff88b3..67ef4e5655b 100644
--- a/tests/ui/cognitive_complexity.stderr
+++ b/tests/ui/cognitive_complexity.stderr
@@ -160,5 +160,21 @@ LL |         pub async fn async_method() {
    |
    = help: you could split it up into multiple smaller functions
 
-error: aborting due to 20 previous errors
+error: the function has a cognitive complexity of (2/1)
+  --> tests/ui/cognitive_complexity.rs:459:8
+   |
+LL |     fn foo() {
+   |        ^^^
+   |
+   = help: you could split it up into multiple smaller functions
+
+error: the function has a cognitive complexity of (2/1)
+  --> tests/ui/cognitive_complexity.rs:466:8
+   |
+LL |     fn bar() {
+   |        ^^^
+   |
+   = help: you could split it up into multiple smaller functions
+
+error: aborting due to 22 previous errors