mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Rollup merge of #89997 - cameron1024:const-str-as-bytes-ice, r=JohnTitor
Add test for issue #84957 - `str.as_bytes()` in a `const` expression Hi, this PR adds a test for issue #84957 . I'm quite new to rustc so let me know if there's anything else that needs doing 😄 Closes #84957
This commit is contained in:
commit
c3cfa58157
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user