]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/const_evaluatable_checked/nested-abstract-consts-2.rs
Merge commit '15c8d31392b9fbab3b3368b67acc4bbe5983115a' into cranelift-rebase
[rust.git] / src / test / ui / const-generics / const_evaluatable_checked / nested-abstract-consts-2.rs
1 // run-pass
2 #![feature(const_evaluatable_checked, const_generics)]
3 #![allow(incomplete_features)]
4
5 struct Generic<const K: u64>;
6
7 struct ConstU64<const K: u64>;
8
9 impl<const K: u64> Generic<K>
10 where
11     ConstU64<{ K - 1 }>: ,
12 {
13     fn foo(self) -> u64 {
14         K
15     }
16 }
17
18 impl<const K: u64> Generic<K>
19 where
20     ConstU64<{ K - 1 }>: ,
21     ConstU64<{ K + 1 }>: ,
22     ConstU64<{ K + 1 - 1 }>: ,
23 {
24     fn bar(self) -> u64 {
25         let x: Generic<{ K + 1 }> = Generic;
26         x.foo()
27     }
28 }
29
30 fn main() {
31     assert_eq!((Generic::<10>).bar(), 11);
32 }
33
34 // Test that the ``ConstU64<{ K + 1 - 1}>`` bound on ``bar``'s impl block satisfies the
35 // ``ConstU64<{K - 1}>`` bound on ``foo``'s impl block