]> git.proxmox.com Git - rustc.git/blob - src/test/ui/rfc-2632-const-trait-impl/specialization/const-default-const-specialized.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / rfc-2632-const-trait-impl / specialization / const-default-const-specialized.rs
1 // Tests that a const default trait impl can be specialized by another const
2 // trait impl and that the specializing impl will be used during const-eval.
3
4 // run-pass
5
6 #![feature(const_trait_impl)]
7 #![feature(min_specialization)]
8
9 #[const_trait]
10 trait Value {
11 fn value() -> u32;
12 }
13
14 const fn get_value<T: ~const Value>() -> u32 {
15 T::value()
16 }
17
18 impl<T> const Value for T {
19 default fn value() -> u32 {
20 0
21 }
22 }
23
24 struct FortyTwo;
25
26 impl const Value for FortyTwo {
27 fn value() -> u32 {
28 42
29 }
30 }
31
32 const ZERO: u32 = get_value::<()>();
33
34 const FORTY_TWO: u32 = get_value::<FortyTwo>();
35
36 fn main() {
37 assert_eq!(ZERO, 0);
38 assert_eq!(FORTY_TWO, 42);
39 }