2020-08-10 18:50:58 +00:00
|
|
|
// Checks that pointers must not be used as the type of const params.
|
2020-08-09 05:01:19 +00:00
|
|
|
// revisions: full min
|
|
|
|
|
2021-08-30 08:59:53 +00:00
|
|
|
#![cfg_attr(full, feature(adt_const_params))]
|
2020-08-09 05:01:19 +00:00
|
|
|
#![cfg_attr(full, allow(incomplete_features))]
|
2019-10-04 21:49:24 +00:00
|
|
|
|
|
|
|
const A: u32 = 3;
|
|
|
|
|
2020-06-12 17:25:14 +00:00
|
|
|
struct Const<const P: *const u32>; //~ ERROR: using raw pointers as const generic parameters
|
2019-10-04 21:49:24 +00:00
|
|
|
|
2020-06-12 17:25:14 +00:00
|
|
|
impl<const P: *const u32> Const<P> { //~ ERROR: using raw pointers as const generic parameters
|
2019-10-04 21:49:24 +00:00
|
|
|
fn get() -> u32 {
|
|
|
|
unsafe {
|
|
|
|
*P
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
assert_eq!(Const::<{&A as *const _}>::get(), 3)
|
2019-10-04 23:57:12 +00:00
|
|
|
}
|