Skip to content

Commit

Permalink
Merge #265
Browse files Browse the repository at this point in the history
265: Remove project, project_ref, and project_replace attributes r=taiki-e a=taiki-e

cc #264

Co-authored-by: Taiki Endo <te316e89@gmail.com>
  • Loading branch information
bors[bot] and taiki-e authored Sep 3, 2020
2 parents 8654dd4 + 8c9a674 commit d9c1af0
Show file tree
Hide file tree
Showing 25 changed files with 0 additions and 1,943 deletions.
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

0 comments on commit d9c1af0

Please sign in to comment.