]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/where-clauses.rs
Rollup merge of #87742 - npmccallum:naked_ffi, r=Amanieu
[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
6 trait Bar<const N: usize> { fn bar() {} }
7 trait Foo<const N: usize>: Bar<N> {}
8
9 fn test<T, const N: usize>() where T: Foo<N> {
10     <T as Bar<N>>::bar();
11 }
12
13 struct Faz<const N: usize>;
14
15 impl<const N: usize> Faz<N> {
16     fn test<T>() where T: Foo<N> {
17         <T as Bar<N>>::bar()
18     }
19 }
20
21 trait Fiz<const N: usize> {
22     fn fiz<T>() where T: Foo<N> {
23         <T as Bar<N>>::bar();
24     }
25 }
26
27 impl<const N: usize> Bar<N> for u8 {}
28 impl<const N: usize> Foo<N> for u8 {}
29 impl<const N: usize> Fiz<N> for u8 {}
30 fn main() {
31     test::<u8, 13>();
32     Faz::<3>::test::<u8>();
33     <u8 as Fiz<13>>::fiz::<u8>();
34 }