about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorAlexey Semenyuk <alexsemenyuk88@gmail.com>2024-10-17 22:36:26 +0500
committerAlexey Semenyuk <alexsemenyuk88@gmail.com>2024-10-17 22:36:26 +0500
commit85559223519ee0d72fa90dc48d92faab36758bd0 (patch)
tree25f5b28f09fee9c092691b33d967ceffe66488c6 /tests
parentdae1be90eeb20d1d5b7b30d3fc4f2a119cee638b (diff)
downloadrust-85559223519ee0d72fa90dc48d92faab36758bd0.tar.gz
rust-85559223519ee0d72fa90dc48d92faab36758bd0.zip
Don't trigger const_is_empty for inline const assertions
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/const_is_empty.rs14
-rw-r--r--tests/ui/const_is_empty.stderr8
2 files changed, 21 insertions, 1 deletions
diff --git a/tests/ui/const_is_empty.rs b/tests/ui/const_is_empty.rs
index 04e0de91ecf..b5e27b61548 100644
--- a/tests/ui/const_is_empty.rs
+++ b/tests/ui/const_is_empty.rs
@@ -171,3 +171,17 @@ fn constant_from_external_crate() {
     let _ = std::env::consts::EXE_EXTENSION.is_empty();
     // Do not lint, `exe_ext` comes from the `std` crate
 }
+
+fn issue_13106() {
+    const {
+        assert!(!NON_EMPTY_STR.is_empty());
+    }
+
+    const {
+        assert!(EMPTY_STR.is_empty());
+    }
+
+    const {
+        EMPTY_STR.is_empty();
+    }
+}
diff --git a/tests/ui/const_is_empty.stderr b/tests/ui/const_is_empty.stderr
index 7f80b520b1a..0afba940d8b 100644
--- a/tests/ui/const_is_empty.stderr
+++ b/tests/ui/const_is_empty.stderr
@@ -157,5 +157,11 @@ error: this expression always evaluates to true
 LL |     let _ = val.is_empty();
    |             ^^^^^^^^^^^^^^
 
-error: aborting due to 26 previous errors
+error: this expression always evaluates to true
+  --> tests/ui/const_is_empty.rs:185:9
+   |
+LL |         EMPTY_STR.is_empty();
+   |         ^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 27 previous errors