]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/slice-const-param.rs
Auto merge of #79342 - CDirkx:ipaddr-const, r=oli-obk
[rust.git] / src / test / ui / const-generics / slice-const-param.rs
1 //[full] run-pass
2 // revisions: min full
3
4 #![cfg_attr(full, feature(const_generics))]
5 #![cfg_attr(full, allow(incomplete_features))]
6 #![cfg_attr(min, feature(min_const_generics))]
7
8 pub fn function_with_str<const STRING: &'static str>() -> &'static str {
9     //[min]~^ ERROR `&'static str` is forbidden
10     STRING
11 }
12
13 pub fn function_with_bytes<const BYTES: &'static [u8]>() -> &'static [u8] {
14     //[min]~^ ERROR `&'static [u8]` is forbidden
15     BYTES
16 }
17
18 pub fn main() {
19     assert_eq!(function_with_str::<"Rust">(), "Rust");
20     assert_eq!(function_with_str::<"ℇ㇈↦">(), "ℇ㇈↦");
21     assert_eq!(function_with_bytes::<b"AAAA">(), &[0x41, 0x41, 0x41, 0x41]);
22     assert_eq!(function_with_bytes::<{&[0x41, 0x41, 0x41, 0x41]}>(), b"AAAA");
23 }