2022-01-23 18:41:37 -06:00
|
|
|
// edition:2021
|
2024-06-19 15:06:53 -05:00
|
|
|
|
2022-01-23 18:41:37 -06:00
|
|
|
use core::marker::PhantomPinned;
|
|
|
|
use core::mem::{drop as stuff, transmute};
|
|
|
|
use core::pin::{Pin, pin};
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn basic() {
|
|
|
|
let it: Pin<&mut PhantomPinned> = pin!(PhantomPinned);
|
|
|
|
stuff(it);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn extension_works_through_block() {
|
|
|
|
let it: Pin<&mut PhantomPinned> = { pin!(PhantomPinned) };
|
|
|
|
stuff(it);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn extension_works_through_unsafe_block() {
|
|
|
|
// "retro-type-inference" works as well.
|
|
|
|
let it: Pin<&mut PhantomPinned> = unsafe { pin!(transmute(())) };
|
|
|
|
stuff(it);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn unsize_coercion() {
|
|
|
|
let slice: Pin<&mut [PhantomPinned]> = pin!([PhantomPinned; 2]);
|
|
|
|
stuff(slice);
|
|
|
|
let dyn_obj: Pin<&mut dyn Send> = pin!([PhantomPinned; 2]);
|
|
|
|
stuff(dyn_obj);
|
|
|
|
}
|