We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents d56360d + 582a171 commit 76548baCopy full SHA for 76548ba
src/test/ui/const-generics/const_evaluatable_checked/elaborate-trait-pred.rs
@@ -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