2021-05-08 14:36:39 +00:00
|
|
|
// run-pass
|
|
|
|
#![feature(slice_ptr_len)]
|
2021-04-19 08:15:56 +00:00
|
|
|
|
|
|
|
use std::ptr::NonNull;
|
|
|
|
|
2021-05-08 14:36:39 +00:00
|
|
|
#[allow(unused)]
|
2021-04-19 08:15:56 +00:00
|
|
|
const fn test() {
|
|
|
|
let _x = NonNull::<[i32; 0]>::dangling() as NonNull<[i32]>;
|
|
|
|
}
|
|
|
|
|
2021-05-08 14:28:29 +00:00
|
|
|
// Regression test for #75118.
|
|
|
|
pub const fn dangling_slice<T>() -> NonNull<[T]> {
|
2021-05-08 14:36:39 +00:00
|
|
|
NonNull::<[T; 1]>::dangling()
|
2021-05-08 14:28:29 +00:00
|
|
|
}
|
|
|
|
|
2021-05-08 14:36:39 +00:00
|
|
|
const C: NonNull<[i32]> = dangling_slice();
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
assert_eq!(C.as_ptr(), NonNull::<[i32; 1]>::dangling().as_ptr() as *mut _);
|
|
|
|
assert_eq!(C.as_ptr().len(), 1);
|
|
|
|
}
|