]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/const-argument-if-length.rs
Auto merge of #77611 - oli-obk:atomic_miri_leakage, r=nagisa
[rust.git] / src / test / ui / const-generics / const-argument-if-length.rs
1 // revisions: full min
2
3 #![cfg_attr(full, allow(incomplete_features))]
4 #![cfg_attr(full, feature(const_generics))]
5 #![cfg_attr(min, feature(min_const_generics))]
6
7 pub const fn is_zst<T: ?Sized>() -> usize {
8     if std::mem::size_of::<T>() == 0 {
9         //[full]~^ ERROR the size for values of type `T` cannot be known at compilation time
10         1
11     } else {
12         0
13     }
14 }
15
16 pub struct AtLeastByte<T: ?Sized> {
17     value: T,
18     //~^ ERROR the size for values of type `T` cannot be known at compilation time
19     pad: [u8; is_zst::<T>()],
20     //[min]~^ ERROR generic parameters may not be used in const operations
21 }
22
23 fn main() {}