]> git.lizzy.rs Git - rust.git/blob - tests/ui/const-generics/raw-ptr-const-param-deref.rs
Rollup merge of #105172 - alexs-sh:issue-98861-fix-next, r=scottmcm
[rust.git] / tests / 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(adt_const_params))]
5 #![cfg_attr(full, allow(incomplete_features))]
6
7 const A: u32 = 3;
8
9 struct Const<const P: *const u32>; //~ ERROR: using raw pointers as const generic parameters
10
11 impl<const P: *const u32> Const<P> { //~ ERROR: using raw pointers as const generic parameters
12     fn get() -> u32 {
13         unsafe {
14             *P
15         }
16     }
17 }
18
19 fn main() {
20     assert_eq!(Const::<{&A as *const _}>::get(), 3)
21 }