mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 22:12:15 +00:00
22 lines
461 B
Rust
22 lines
461 B
Rust
// run-pass
|
|
#![feature(slice_ptr_len)]
|
|
|
|
use std::ptr::NonNull;
|
|
|
|
#[allow(unused)]
|
|
const fn test() {
|
|
let _x = NonNull::<[i32; 0]>::dangling() as NonNull<[i32]>;
|
|
}
|
|
|
|
// Regression test for #75118.
|
|
pub const fn dangling_slice<T>() -> NonNull<[T]> {
|
|
NonNull::<[T; 1]>::dangling()
|
|
}
|
|
|
|
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);
|
|
}
|