Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/consteval/tests.rs')
-rw-r--r--crates/hir-ty/src/consteval/tests.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/crates/hir-ty/src/consteval/tests.rs b/crates/hir-ty/src/consteval/tests.rs
index 41e0b5188b..167854f3ed 100644
--- a/crates/hir-ty/src/consteval/tests.rs
+++ b/crates/hir-ty/src/consteval/tests.rs
@@ -1830,6 +1830,38 @@ fn byte_string() {
}
#[test]
+fn c_string() {
+ check_number(
+ r#"
+//- minicore: index, slice
+#[lang = "CStr"]
+pub struct CStr {
+ inner: [u8]
+}
+const GOAL: u8 = {
+ let a = c"hello";
+ a.inner[0]
+};
+ "#,
+ 104,
+ );
+ check_number(
+ r#"
+//- minicore: index, slice
+#[lang = "CStr"]
+pub struct CStr {
+ inner: [u8]
+}
+const GOAL: u8 = {
+ let a = c"hello";
+ a.inner[6]
+};
+ "#,
+ 0,
+ );
+}
+
+#[test]
fn consts() {
check_number(
r#"