From e18b27aa2a37fb7597c16f72a55f26bde6badf51 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Fri, 24 May 2024 10:37:19 +0700 Subject: [PATCH] add uitest for issue 12816 --- tests/ui/assertions_on_constants.rs | 6 ++++++ tests/ui/assertions_on_constants.stderr | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) 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