]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/raw-ptr-const-param-deref.rs
Auto merge of #79342 - CDirkx:ipaddr-const, r=oli-obk
[rust.git] / src / test / ui / const-generics / raw-ptr-const-param-deref.rs
1 // Checks that pointers must not be used as the type of const params.
2 // revisions: full min
3
4 #![cfg_attr(full, feature(const_generics))]
5 #![cfg_attr(full, allow(incomplete_features))]
6 #![cfg_attr(min, feature(min_const_generics))]
7
8 const A: u32 = 3;
9
10 struct Const<const P: *const u32>; //~ ERROR: using raw pointers as const generic parameters
11
12 impl<const P: *const u32> Const<P> { //~ ERROR: using raw pointers as const generic parameters
13     fn get() -> u32 {
14         unsafe {
15             *P
16         }
17     }
18 }
19
20 fn main() {
21     assert_eq!(Const::<{&A as *const _}>::get(), 3)
22 }