diff --git a/pin-project-internal/src/pin_project/mod.rs b/pin-project-internal/src/pin_project/mod.rs index 3fc00650..f9e49626 100644 --- a/pin-project-internal/src/pin_project/mod.rs +++ b/pin-project-internal/src/pin_project/mod.rs @@ -42,7 +42,7 @@ impl Parse for Args { let i = input.parse::()?; match &*i.to_string() { "PinnedDrop" => pinned_drop = Some(i.span()), - "unsafe_Unpin" => unsafe_unpin = Some(i.span()), + "UnsafeUnpin" => unsafe_unpin = Some(i.span()), _ => return Err(error!(i, "an invalid argument was passed")), } } diff --git a/src/lib.rs b/src/lib.rs index 28ad9714..8fb8dd8d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -243,7 +243,7 @@ pub use pin_project_internal::project; /// To enforce this, this attribute will automatically generate an `Unpin` implementation /// for you, which will require that all structurally pinned fields be `Unpin` /// If you wish to provide an manual `Unpin` impl, you can do so via the -/// `unsafe_Unpin` argument. +/// `UnsafeUnpin` argument. /// /// 2. The destructor of the struct must not move structural fields out of its argument. /// @@ -300,14 +300,14 @@ pub use pin_project_internal::project; /// ``` /// /// If you want to implement [`Unpin`] manually, -/// you must use the `unsafe_Unpin` argument to +/// you must use the `UnsafeUnpin` argument to /// `#[pin_project]`. /// /// ```rust /// use pin_project::{pin_project, UnsafeUnpin}; /// use std::pin::Pin; /// -/// #[pin_project(unsafe_Unpin)] +/// #[pin_project(UnsafeUnpin)] /// struct Foo { /// #[pin] /// future: T, @@ -509,7 +509,7 @@ pub use pin_project_internal::pin_project; pub use pin_project_internal::pinned_drop; /// A trait used for custom implementations of [`Unpin`]. -/// This trait is used in conjunction with the `unsafe_Unpin` +/// This trait is used in conjunction with the `UnsafeUnpin` /// argument to [`pin_project`] /// /// The Rust [`Unpin`] trait is safe to implement - by itself, @@ -532,10 +532,10 @@ pub use pin_project_internal::pinned_drop; /// this crate will generate an `Unpin` impl for your type that 'forwards' to /// your `UnsafeUnpin` impl. However, this trait is `unsafe` - since your type /// uses structural pinning (otherwise, you wouldn't be using this crate!), -/// you must be sure that your `UnsafeUnpinned` impls follows all of +/// you must be sure that your `UnsafeUnpin` impls follows all of /// the requirements for an `Unpin` impl of a structurally-pinned type. /// -/// Note that if you specify `#[pin_project(unsafe_Unpin)]`, but do *not* +/// Note that if you specify `#[pin_project(UnsafeUnpin)]`, but do *not* /// provide an impl of `UnsafeUnpin`, your type will never implement `Unpin`. /// This is effectly the same thing as adding a `PhantomUnpin` to your type /// @@ -550,7 +550,7 @@ pub use pin_project_internal::pinned_drop; /// ```rust /// use pin_project::{pin_project, UnsafeUnpin}; /// -/// #[pin_project(unsafe_Unpin)] +/// #[pin_project(UnsafeUnpin)] /// struct Foo { /// #[pin] /// field_1: K, @@ -586,47 +586,47 @@ pub mod __private { // This is an internal helper struct used by `pin-project-internal`. // This allows us to force an error if the user tries to provide - // a regular `Unpin` impl when they specify the `unsafe_Unpin` argument. + // a regular `Unpin` impl when they specify the `UnsafeUnpin` argument. // This is why we need Wrapper: // // Supposed we have the following code: // - // #[pin_project(unsafe_Unpin)] + // #[pin_project(UnsafeUnpin)] // struct MyStruct { // #[pin] field: T // } // - // impl Unpin for MyStruct where MyStruct: UnsafeUnpinned {} // generated by pin-project-internal + // impl Unpin for MyStruct where MyStruct: UnsafeUnpin {} // generated by pin-project-internal // impl Unpin for MyStruct where T: Copy // written by the user // - // We want this code to be rejected - the user is completely bypassing unsafe_Unpin, + // We want this code to be rejected - the user is completely bypassing `UnsafeUnpin`, // and providing an unsound Unpin impl in safe code! // // Unfortunately, the Rust compiler will accept the above code. // Because MyStruct is declared in the same crate as the user-provided impl, - // the compiler will notice that 'MyStruct: UnsafeUnpinned' never holds. + // the compiler will notice that 'MyStruct: UnsafeUnpin' never holds. // // The solution is to introduce the 'Wrapper' struct, which is defined // in the 'pin-project' crate. // // We now have code that looks like this: // - // impl Unpin for MyStruct where Wrapper>: UnsafeUnpinned {} // generated by pin-project-internal + // impl Unpin for MyStruct where Wrapper>: UnsafeUnpin {} // generated by pin-project-internal // impl Unpin for MyStruct where T: Copy // written by the user // // We also have 'unsafe impl UnsafeUnpin for Wrapper where T: UnsafeUnpin {}' in the // 'pin-project' crate. // // Now, our generated impl has a bound involving a type defined in another crate - Wrapper. - // This will cause rust to conservatively assume that 'Wrapper>: UnsafeUnpinned' + // This will cause rust to conservatively assume that 'Wrapper>: UnsafeUnpin' // holds, in the interest of preserving forwards compatibility (in case such an impl is added // for Wrapper in a new version of the crate). // // This will cause rust to reject any other Unpin impls for MyStruct, since it will // assume that our generated impl could potentially apply in any situation. // - // This acheives the desired effect - when the user writes `#[pin_project(unsafe_Unpin)]`, - // the user must either provide no impl of `UnsafeUnpinned` (which is equivalent + // This acheives the desired effect - when the user writes `#[pin_project(UnsafeUnpin)]`, + // the user must either provide no impl of `UnsafeUnpin` (which is equivalent // to making the type never implement Unpin), or provide an impl of `UnsafeUnpin`. // It is impossible for them to provide an impl of `Unpin` #[doc(hidden)] diff --git a/tests/ui/pin_project/forget-unsafe-unpin.rs b/tests/ui/pin_project/forget-unsafe-unpin.rs index e156bf1f..2e2d9172 100644 --- a/tests/ui/pin_project/forget-unsafe-unpin.rs +++ b/tests/ui/pin_project/forget-unsafe-unpin.rs @@ -7,7 +7,7 @@ use pin_project::pin_project; // FIXME #[test] fn unsafe_unpin() { - #[pin_project(unsafe_Unpin)] + #[pin_project(UnsafeUnpin)] pub struct Blah { field_1: u8, #[pin] diff --git a/tests/unsafe_unpin.rs b/tests/unsafe_unpin.rs index 157b7582..cba65dd5 100644 --- a/tests/unsafe_unpin.rs +++ b/tests/unsafe_unpin.rs @@ -7,7 +7,7 @@ use pin_project::{pin_project, UnsafeUnpin}; #[test] fn unsafe_unpin() { - #[pin_project(unsafe_Unpin)] + #[pin_project(UnsafeUnpin)] pub struct Blah { field_1: u8, #[pin]