]> git.proxmox.com Git - rustc.git/blob - src/test/ui/const-generics/const-argument-if-length.rs
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / src / test / ui / const-generics / const-argument-if-length.rs
1 // revisions: full min
2
3 #![cfg_attr(full, feature(generic_const_exprs))]
4 #![cfg_attr(full, allow(incomplete_features))]
5
6 pub const fn is_zst<T: ?Sized>() -> usize {
7 if std::mem::size_of::<T>() == 0 {
8 1
9 } else {
10 0
11 }
12 }
13
14 pub struct AtLeastByte<T: ?Sized> {
15 value: T,
16 //~^ ERROR the size for values of type `T` cannot be known at compilation time
17 pad: [u8; is_zst::<T>()],
18 //[min]~^ ERROR generic parameters may not be used in const operations
19 //[full]~^^ ERROR unconstrained generic constant
20 }
21
22 fn main() {}