1 // check-pass
2 #![allow(dead_code)]
3
foo<T>()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
test()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
test()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
main()34 fn main() {}
35