Skip to content

Commit 76548ba

Browse files
authored
Rollup merge of #81430 - lcnr:elaborate-const-eval, r=oli-obk
add const_evaluatable_checked test cc `````@oli-obk`````
2 parents d56360d + 582a171 commit 76548ba

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// run-pass
2+
// Test that we use the elaborated predicates from traits
3+
// to satisfy const evaluatable predicates.
4+
#![feature(const_generics, const_evaluatable_checked)]
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+
}

0 commit comments

Comments
 (0)