mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 14:01:51 +00:00
84ac80f192
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
33 lines
734 B
Rust
33 lines
734 B
Rust
// edition:2021
|
|
|
|
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);
|
|
}
|