]> git.proxmox.com Git - rustc.git/blob - src/test/ui/const-generics/where-clauses.rs
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / src / test / ui / const-generics / where-clauses.rs
1 // check-pass
2 trait Bar<const N: usize> { fn bar() {} }
3 trait Foo<const N: usize>: Bar<N> {}
4
5 fn test<T, const N: usize>() where T: Foo<N> {
6 <T as Bar<N>>::bar();
7 }
8
9 struct Faz<const N: usize>;
10
11 impl<const N: usize> Faz<N> {
12 fn test<T>() where T: Foo<N> {
13 <T as Bar<N>>::bar()
14 }
15 }
16
17 trait Fiz<const N: usize> {
18 fn fiz<T>() where T: Foo<N> {
19 <T as Bar<N>>::bar();
20 }
21 }
22
23 impl<const N: usize> Bar<N> for u8 {}
24 impl<const N: usize> Foo<N> for u8 {}
25 impl<const N: usize> Fiz<N> for u8 {}
26 fn main() {
27 test::<u8, 13>();
28 Faz::<3>::test::<u8>();
29 <u8 as Fiz<13>>::fiz::<u8>();
30 }