]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/generic_const_exprs/elaborate-trait-pred.rs
Move generic error message to separate branches
[rust.git] / src / test / ui / const-generics / generic_const_exprs / elaborate-trait-pred.rs
1 // run-pass
2 // Test that we use the elaborated predicates from traits
3 // to satisfy const evaluatable predicates.
4 #![feature(generic_const_exprs)]
5 #![allow(incomplete_features)]
6 use std::mem::size_of;
7
8 trait Foo: Sized
9 where
10     [(); size_of::<Self>()]: Sized,
11 {
12 }
13
14 impl Foo for u64 {}
15 impl Foo for u32 {}
16
17 fn foo<T: Foo>() -> [u8; size_of::<T>()] {
18     [0; size_of::<T>()]
19 }
20
21 fn main() {
22     assert_eq!(foo::<u32>(), [0; 4]);
23     assert_eq!(foo::<u64>(), [0; 8]);
24 }