about summary refs log tree commit diff
path: root/tests/ui/consts/const-eval/issue-84957-const-str-as-bytes.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/consts/const-eval/issue-84957-const-str-as-bytes.rs')
-rw-r--r--tests/ui/consts/const-eval/issue-84957-const-str-as-bytes.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/ui/consts/const-eval/issue-84957-const-str-as-bytes.rs b/tests/ui/consts/const-eval/issue-84957-const-str-as-bytes.rs
new file mode 100644
index 00000000000..7e235c4911c
--- /dev/null
+++ b/tests/ui/consts/const-eval/issue-84957-const-str-as-bytes.rs
@@ -0,0 +1,28 @@
+// build-pass
+
+trait Foo {}
+
+struct Bar {
+    bytes: &'static [u8],
+    func: fn(&Box<dyn Foo>),
+}
+fn example(_: &Box<dyn Foo>) {}
+
+const BARS: &[Bar] = &[
+    Bar {
+        bytes: "0".as_bytes(),
+        func: example,
+    },
+    Bar {
+        bytes: "0".as_bytes(),
+        func: example,
+    },
+];
+
+fn main() {
+    let x = todo!();
+
+    for bar in BARS {
+        (bar.func)(&x);
+    }
+}