From f8b2f91c4879bbb37ed64623373a1b95b658bc20 Mon Sep 17 00:00:00 2001 From: cameron Date: Mon, 18 Oct 2021 08:41:18 +0100 Subject: [PATCH] add test for issue 84957 --- .../issue-84957-const-str-as-bytes.rs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/test/ui/consts/const-eval/issue-84957-const-str-as-bytes.rs diff --git a/src/test/ui/consts/const-eval/issue-84957-const-str-as-bytes.rs b/src/test/ui/consts/const-eval/issue-84957-const-str-as-bytes.rs new file mode 100644 index 00000000000..7e235c4911c --- /dev/null +++ b/src/test/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), +} +fn example(_: &Box) {} + +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); + } +}