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