]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/min_const_generics/const-evaluatable-unchecked.rs
Add tests for `#[no_mangle]` in `impl` blocks that looks like generic `impl` blocks...
[rust.git] / src / test / ui / const-generics / min_const_generics / const-evaluatable-unchecked.rs
1 // check-pass
2 #![allow(dead_code)]
3
4 fn foo<T>() {
5     [0; std::mem::size_of::<*mut T>()];
6     //~^ WARN cannot use constants which depend on generic parameters in types
7     //~| WARN this was previously accepted by the compiler but is being phased out
8 }
9
10 struct Foo<T>(T);
11
12 impl<T> Foo<T> {
13     const ASSOC: usize = 4;
14
15     fn test() {
16         let _ = [0; Self::ASSOC];
17         //~^ WARN cannot use constants which depend on generic parameters in types
18         //~| WARN this was previously accepted by the compiler but is being phased out
19     }
20 }
21
22 struct Bar<const N: usize>;
23
24 impl<const N: usize> Bar<N> {
25     const ASSOC: usize = 4;
26
27     fn test() {
28         let _ = [0; Self::ASSOC];
29         //~^ WARN cannot use constants which depend on generic parameters in types
30         //~| WARN this was previously accepted by the compiler but is being phased out
31     }
32 }
33
34 fn main() {}