]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/slice-const-param.rs
Auto merge of #87150 - rusticstuff:simplify_wrapping_neg, r=m-ou-se
[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
7 pub fn function_with_str<const STRING: &'static str>() -> &'static str {
8     //[min]~^ ERROR `&'static str` is forbidden
9     STRING
10 }
11
12 pub fn function_with_bytes<const BYTES: &'static [u8]>() -> &'static [u8] {
13     //[min]~^ ERROR `&'static [u8]` is forbidden
14     BYTES
15 }
16
17 pub fn main() {
18     assert_eq!(function_with_str::<"Rust">(), "Rust");
19     assert_eq!(function_with_str::<"ℇ㇈↦">(), "ℇ㇈↦");
20     assert_eq!(function_with_bytes::<b"AAAA">(), &[0x41, 0x41, 0x41, 0x41]);
21     assert_eq!(function_with_bytes::<{&[0x41, 0x41, 0x41, 0x41]}>(), b"AAAA");
22 }