Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove project, project_ref, and project_replace attributes #265

Merged
merged 1 commit into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions pin-project-internal/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ fn main() {
if minor >= 37 {
println!("cargo:rustc-cfg=underscore_consts");
}

// #[deprecated] on proc-macro requires Rust 1.40:
// https://github.com/rust-lang/rust/pull/65666
if minor >= 40 {
println!("cargo:rustc-cfg=deprecated_proc_macro");
}
}

fn rustc_minor_version() -> Option<u32> {
Expand Down
232 changes: 0 additions & 232 deletions pin-project-internal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@ mod utils;

mod pin_project;
mod pinned_drop;
mod project;

use proc_macro::TokenStream;

use crate::utils::ProjKind;

/// An attribute that creates projection types covering all the fields of
/// struct or enum.
///
Expand Down Expand Up @@ -531,235 +528,6 @@ pub fn pinned_drop(args: TokenStream, input: TokenStream) -> TokenStream {
pinned_drop::attribute(&args.into(), input).into()
}

/// (deprecated) An attribute to provide way to refer to the projected type returned by
/// `project` method.
///
/// **This attribute is deprecated. Consider naming projected type by passing
/// `project` argument to `#[pin_project]` attribute instead, see [release note]
/// for details**
///
/// The following syntaxes are supported.
///
/// # `let` bindings
///
/// *The attribute at the expression position is not stable, so you need to use
/// a dummy `#[project]` attribute for the function.*
///
/// ## Examples
///
/// ```rust
/// # #![allow(deprecated)]
/// use pin_project::{pin_project, project};
/// use std::pin::Pin;
///
/// #[pin_project]
/// struct Foo<T, U> {
/// #[pin]
/// future: T,
/// field: U,
/// }
///
/// impl<T, U> Foo<T, U> {
/// #[project] // Nightly does not need a dummy attribute to the function.
/// fn baz(self: Pin<&mut Self>) {
/// #[project]
/// let Foo { future, field } = self.project();
///
/// let _: Pin<&mut T> = future;
/// let _: &mut U = field;
/// }
/// }
/// ```
///
/// # `match` expressions
///
/// *The attribute at the expression position is not stable, so you need to use
/// a dummy `#[project]` attribute for the function.*
///
/// ## Examples
///
/// ```rust
/// # #![allow(deprecated)]
/// use pin_project::{pin_project, project};
/// use std::pin::Pin;
///
/// #[pin_project]
/// enum Enum<A, B, C> {
/// Tuple(#[pin] A, B),
/// Struct { field: C },
/// Unit,
/// }
///
/// impl<A, B, C> Enum<A, B, C> {
/// #[project] // Nightly does not need a dummy attribute to the function.
/// fn baz(self: Pin<&mut Self>) {
/// #[project]
/// match self.project() {
/// Enum::Tuple(x, y) => {
/// let _: Pin<&mut A> = x;
/// let _: &mut B = y;
/// }
/// Enum::Struct { field } => {
/// let _: &mut C = field;
/// }
/// Enum::Unit => {}
/// }
/// }
/// }
/// ```
///
/// # `impl` blocks
///
/// All methods and associated functions in `#[project] impl` block become
/// methods of the projected type. If you want to implement methods on the
/// original type, you need to create another (non-`#[project]`) `impl` block.
///
/// To call a method implemented in `#[project] impl` block, you need to first
/// get the projected-type with `let this = self.project();`.
///
/// ## Examples
///
/// ```rust
/// # #![allow(deprecated)]
/// use pin_project::{pin_project, project};
/// use std::pin::Pin;
///
/// #[pin_project]
/// struct Foo<T, U> {
/// #[pin]
/// future: T,
/// field: U,
/// }
///
/// // impl for the original type
/// impl<T, U> Foo<T, U> {
/// fn bar(self: Pin<&mut Self>) {
/// self.project().baz()
/// }
/// }
///
/// // impl for the projected type
/// #[project]
/// impl<T, U> Foo<T, U> {
/// fn baz(self) {
/// let Self { future, field } = self;
///
/// let _: Pin<&mut T> = future;
/// let _: &mut U = field;
/// }
/// }
/// ```
///
/// # `use` statements
///
/// ## Examples
///
/// ```rust
/// # #![allow(deprecated)]
/// # mod dox {
/// use pin_project::pin_project;
///
/// #[pin_project]
/// struct Foo<A> {
/// #[pin]
/// field: A,
/// }
///
/// mod bar {
/// use super::Foo;
/// use pin_project::project;
/// use std::pin::Pin;
///
/// #[project]
/// use super::Foo;
///
/// #[project]
/// fn baz<A>(foo: Pin<&mut Foo<A>>) {
/// #[project]
/// let Foo { field } = foo.project();
/// let _: Pin<&mut A> = field;
/// }
/// }
/// # }
/// ```
///
/// [release note]: https://github.com/taiki-e/pin-project/releases/tag/v0.4.21
#[cfg_attr(
deprecated_proc_macro,
deprecated(
since = "0.4.21",
note = "consider naming projected type by passing `project` \
argument to #[pin_project] attribute instead, see release note \
<https://github.com/taiki-e/pin-project/releases/tag/v0.4.21> \
for details"
)
)]
#[proc_macro_attribute]
pub fn project(args: TokenStream, input: TokenStream) -> TokenStream {
let input = syn::parse_macro_input!(input);
project::attribute(&args.into(), input, ProjKind::Mutable).into()
}

/// (deprecated) An attribute to provide way to refer to the projected type returned by
/// `project_ref` method.
///
/// **This attribute is deprecated. Consider naming projected type by passing
/// `project_ref` argument to `#[pin_project]` attribute instead, see [release note]
/// for details**
///
/// This is the same as [`#[project]`][`project`] attribute except it refers to
/// the projected type returned by the `project_ref` method.
///
/// See [`#[project]`][`project`] attribute for more details.
///
/// [release note]: https://github.com/taiki-e/pin-project/releases/tag/v0.4.21
/// [`project`]: ./attr.project.html
#[cfg_attr(
deprecated_proc_macro,
deprecated(
since = "0.4.21",
note = "consider naming projected type by passing `project_ref` \
argument to #[pin_project] attribute instead, see release note \
<https://github.com/taiki-e/pin-project/releases/tag/v0.4.21> \
for details"
)
)]
#[proc_macro_attribute]
pub fn project_ref(args: TokenStream, input: TokenStream) -> TokenStream {
let input = syn::parse_macro_input!(input);
project::attribute(&args.into(), input, ProjKind::Immutable).into()
}

/// (deprecated) An attribute to provide way to refer to the projected type returned by
/// `project_replace` method.
///
/// **This attribute is deprecated. Consider naming projected type by passing
/// `project_replace` argument to `#[pin_project]` attribute instead, see [release note]
/// for details**
///
/// This is the same as [`#[project]`][`project`] attribute except it refers to
/// the projected type returned by the `project_replace` method.
///
/// See [`#[project]`][`project`] attribute for more details.
///
/// [release note]: https://github.com/taiki-e/pin-project/releases/tag/v0.4.21
/// [`project`]: ./attr.project.html
#[cfg_attr(
deprecated_proc_macro,
deprecated(
since = "0.4.21",
note = "consider naming projected type by passing `project_replace` \
argument to #[pin_project] attribute instead, see release note \
<https://github.com/taiki-e/pin-project/releases/tag/v0.4.21> \
for details"
)
)]
#[proc_macro_attribute]
pub fn project_replace(args: TokenStream, input: TokenStream) -> TokenStream {
let input = syn::parse_macro_input!(input);
project::attribute(&args.into(), input, ProjKind::Owned).into()
}

// An internal helper macro. Not public API.
#[doc(hidden)]
#[proc_macro_derive(__PinProjectInternalDerive, attributes(pin))]
Expand Down
Loading