]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/where-clauses.rs
Auto merge of #79342 - CDirkx:ipaddr-const, r=oli-obk
[rust.git] / src / test / ui / const-generics / where-clauses.rs
1 // check-pass
2 // revisions: full min
3 #![cfg_attr(full, feature(const_generics))]
4 #![cfg_attr(full, allow(incomplete_features))]
5 #![cfg_attr(min, feature(min_const_generics))]
6
7 trait Bar<const N: usize> { fn bar() {} }
8 trait Foo<const N: usize>: Bar<N> {}
9
10 fn test<T, const N: usize>() where T: Foo<N> {
11     <T as Bar<N>>::bar();
12 }
13
14 struct Faz<const N: usize>;
15
16 impl<const N: usize> Faz<N> {
17     fn test<T>() where T: Foo<N> {
18         <T as Bar<N>>::bar()
19     }
20 }
21
22 trait Fiz<const N: usize> {
23     fn fiz<T>() where T: Foo<N> {
24         <T as Bar<N>>::bar();
25     }
26 }
27
28 impl<const N: usize> Bar<N> for u8 {}
29 impl<const N: usize> Foo<N> for u8 {}
30 impl<const N: usize> Fiz<N> for u8 {}
31 fn main() {
32     test::<u8, 13>();
33     Faz::<3>::test::<u8>();
34     <u8 as Fiz<13>>::fiz::<u8>();
35 }