about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLzu Tao <taolzu@gmail.com>2024-05-24 10:37:19 +0700
committerLzu Tao <taolzu@gmail.com>2024-06-08 16:50:25 +0700
commite18b27aa2a37fb7597c16f72a55f26bde6badf51 (patch)
treec5d5dc99b1f46df72c0df9aa0682ec4e9f9e2b49
parent2c61b4557688aca993f59d2170673e86c4df9101 (diff)
downloadrust-e18b27aa2a37fb7597c16f72a55f26bde6badf51.tar.gz
rust-e18b27aa2a37fb7597c16f72a55f26bde6badf51.zip
add uitest for issue 12816
-rw-r--r--tests/ui/assertions_on_constants.rs6
-rw-r--r--tests/ui/assertions_on_constants.stderr18
2 files changed, 23 insertions, 1 deletions
diff --git a/tests/ui/assertions_on_constants.rs b/tests/ui/assertions_on_constants.rs
index 1309ae45d0a..2e0fee08a59 100644
--- a/tests/ui/assertions_on_constants.rs
+++ b/tests/ui/assertions_on_constants.rs
@@ -53,3 +53,9 @@ fn main() {
     const N: usize = 1024;
     const _: () = assert!(N.is_power_of_two());
 }
+
+#[allow(clippy::eq_op)]
+const _: () = {
+    assert!(true);
+    assert!(8 == (7 + 1));
+};
diff --git a/tests/ui/assertions_on_constants.stderr b/tests/ui/assertions_on_constants.stderr
index 00f117c9492..3a64f1892ad 100644
--- a/tests/ui/assertions_on_constants.stderr
+++ b/tests/ui/assertions_on_constants.stderr
@@ -80,5 +80,21 @@ LL |     const _: () = assert!(true);
    |
    = help: remove it
 
-error: aborting due to 10 previous errors
+error: `assert!(true)` will be optimized out by the compiler
+  --> tests/ui/assertions_on_constants.rs:59:5
+   |
+LL |     assert!(true);
+   |     ^^^^^^^^^^^^^
+   |
+   = help: remove it
+
+error: `assert!(true)` will be optimized out by the compiler
+  --> tests/ui/assertions_on_constants.rs:60:5
+   |
+LL |     assert!(8 == (7 + 1));
+   |     ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: remove it
+
+error: aborting due to 12 previous errors