about summary refs log tree commit diff
path: root/tests/ui
diff options
context:
space:
mode:
authorPhilipp Krones <hello@philkrones.com>2025-03-23 11:19:41 +0000
committerGitHub <noreply@github.com>2025-03-23 11:19:41 +0000
commit07e7414fb11bc6b3a304129f1698bee6a92eb197 (patch)
treea6becc2465e9d6c0d79832e569406fb1696d076e /tests/ui
parentcad9083d7109a9003111c5ab886749b4c11cd250 (diff)
parent282b61b64174f8dca382932c5f5f3385c28c4a11 (diff)
downloadrust-07e7414fb11bc6b3a304129f1698bee6a92eb197.tar.gz
rust-07e7414fb11bc6b3a304129f1698bee6a92eb197.zip
fix: `nonminimal_bool` wrongly showed the macro definition (#14424)
Closes #14404

changelog: [`nonminimal_bool`]: fix macro definition wrongly showed in
suggestions.
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/nonminimal_bool.rs20
-rw-r--r--tests/ui/nonminimal_bool.stderr10
2 files changed, 28 insertions, 2 deletions
diff --git a/tests/ui/nonminimal_bool.rs b/tests/ui/nonminimal_bool.rs
index a155ff3508b..1eecc3dee3d 100644
--- a/tests/ui/nonminimal_bool.rs
+++ b/tests/ui/nonminimal_bool.rs
@@ -216,3 +216,23 @@ fn issue14184(a: f32, b: bool) {
         println!("Hi");
     }
 }
+
+mod issue14404 {
+    enum TyKind {
+        Ref(i32, i32, i32),
+        Other,
+    }
+
+    struct Expr;
+
+    fn is_mutable(expr: &Expr) -> bool {
+        todo!()
+    }
+
+    fn should_not_give_macro(ty: TyKind, expr: Expr) {
+        if !(matches!(ty, TyKind::Ref(_, _, _)) && !is_mutable(&expr)) {
+            //~^ nonminimal_bool
+            todo!()
+        }
+    }
+}
diff --git a/tests/ui/nonminimal_bool.stderr b/tests/ui/nonminimal_bool.stderr
index 336cce40abf..0e3e4cf7988 100644
--- a/tests/ui/nonminimal_bool.stderr
+++ b/tests/ui/nonminimal_bool.stderr
@@ -227,7 +227,13 @@ error: this boolean expression can be simplified
   --> tests/ui/nonminimal_bool.rs:214:8
    |
 LL |     if !(a < 2.0 && !b) {
-   |        ^^^^^^^^^^^^^^^^ help: try: `!(a < 2.0) || b`
+   |        ^^^^^^^^^^^^^^^^ help: try: `a >= 2.0 || b`
 
-error: aborting due to 30 previous errors
+error: this boolean expression can be simplified
+  --> tests/ui/nonminimal_bool.rs:233:12
+   |
+LL |         if !(matches!(ty, TyKind::Ref(_, _, _)) && !is_mutable(&expr)) {
+   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `!matches!(ty, TyKind::Ref(_, _, _)) || is_mutable(&expr)`
+
+error: aborting due to 31 previous errors