]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/const_evaluatable_checked/associated-consts.rs
look at assoc ct, check the type of nodes
[rust.git] / src / test / ui / const-generics / const_evaluatable_checked / associated-consts.rs
1 // run-pass
2 #![feature(const_generics, const_evaluatable_checked)]
3 #![allow(incomplete_features)]
4
5 pub trait BlockCipher {
6     const BLOCK_SIZE: usize;
7 }
8
9 struct FooCipher;
10 impl BlockCipher for FooCipher {
11     const BLOCK_SIZE: usize = 64;
12 }
13
14 struct BarCipher;
15 impl BlockCipher for BarCipher {
16     const BLOCK_SIZE: usize = 32;
17 }
18
19 pub struct Block<C>(C);
20
21 pub fn test<C: BlockCipher, const M: usize>()
22 where
23     [u8; M - C::BLOCK_SIZE]: Sized,
24 {
25     let _ = [0; M - C::BLOCK_SIZE];
26 }
27
28 fn main() {
29     test::<FooCipher, 128>();
30     test::<BarCipher, 64>();
31 }