diff options
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.rs | 28 |
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 000000000..7e235c491 --- /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); + } +} |