]> git.lizzy.rs Git - rust.git/blob - src/test/ui/feature-gates/feature-gate-unsafe_pin_internals.rs
parser will not give wrong help message for 'public'
[rust.git] / src / test / ui / feature-gates / feature-gate-unsafe_pin_internals.rs
1 // edition:2018
2 #![forbid(incomplete_features, unsafe_code)]
3 #![feature(unsafe_pin_internals)]
4 //~^ ERROR the feature `unsafe_pin_internals` is incomplete and may not be safe to use
5
6 use core::{marker::PhantomPinned, pin::Pin};
7
8 /// The `unsafe_pin_internals` is indeed unsound.
9 fn non_unsafe_pin_new_unchecked<T>(pointer: &mut T) -> Pin<&mut T> {
10     Pin { pointer }
11 }
12
13 fn main() {
14     let mut self_referential = PhantomPinned;
15     let _: Pin<&mut PhantomPinned> = non_unsafe_pin_new_unchecked(&mut self_referential);
16     core::mem::forget(self_referential); // move and disable drop glue!
17 }