2020-08-09 05:01:19 +00:00
|
|
|
// Assert that cannot use const generics as ptrs and cannot deref them.
|
|
|
|
// revisions: full min
|
|
|
|
|
|
|
|
#![cfg_attr(full, feature(const_generics))]
|
|
|
|
#![cfg_attr(full, allow(incomplete_features))]
|
|
|
|
#![cfg_attr(min, feature(min_const_generics))]
|
2019-10-05 10:49:24 +13:00
|
|
|
|
|
|
|
const A: u32 = 3;
|
|
|
|
|
2020-06-12 19:25:14 +02:00
|
|
|
struct Const<const P: *const u32>; //~ ERROR: using raw pointers as const generic parameters
|
2019-10-05 10:49:24 +13:00
|
|
|
|
2020-06-12 19:25:14 +02:00
|
|
|
impl<const P: *const u32> Const<P> { //~ ERROR: using raw pointers as const generic parameters
|
2019-10-05 10:49:24 +13:00
|
|
|
fn get() -> u32 {
|
|
|
|
unsafe {
|
|
|
|
*P
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
assert_eq!(Const::<{&A as *const _}>::get(), 3)
|
2019-10-05 12:57:12 +13:00
|
|
|
}
|