Skip to content

Commit

Permalink
add test for issue 84957
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron1024 committed Oct 18, 2021
1 parent e1e9319 commit f8b2f91
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/test/ui/consts/const-eval/issue-84957-const-str-as-bytes.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit f8b2f91

Please sign in to comment.