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

Move most of the processing to proc-macro-derive #135

Merged
merged 2 commits into from
Oct 14, 2019
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
8 changes: 2 additions & 6 deletions examples/pinned_drop-expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,8 @@ fn __unpin_scope_Foo() {
#[allow(non_snake_case)]
#[deny(safe_packed_borrows)]
fn __pin_project_assert_not_repr_packed_Foo<'a, T>(val: &Foo<'a, T>) {
{
&val.was_dropped;
}
{
&val.field;
}
&val.was_dropped;
&val.field;
}

fn main() {}
8 changes: 2 additions & 6 deletions examples/struct-default-expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,8 @@ impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[allow(non_snake_case)]
#[deny(safe_packed_borrows)]
fn __pin_project_assert_not_repr_packed_Struct<T, U>(val: &Struct<T, U>) {
{
&val.pinned;
}
{
&val.unpinned;
}
&val.pinned;
&val.unpinned;
}

fn main() {}
8 changes: 2 additions & 6 deletions examples/unsafe_unpin-expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,8 @@ impl<T, U> FooMustNotImplDrop for Foo<T, U> {}
#[allow(non_snake_case)]
#[deny(safe_packed_borrows)]
fn __pin_project_assert_not_repr_packed_Foo<T, U>(val: &Foo<T, U>) {
{
&val.pinned;
}
{
&val.unpinned;
}
&val.pinned;
&val.unpinned;
}

fn main() {}
11 changes: 5 additions & 6 deletions pin-project-internal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,7 @@ use utils::{Immutable, Mutable};
/// [`pinned_drop`]: ./attr.pinned_drop.html
#[proc_macro_attribute]
pub fn pin_project(args: TokenStream, input: TokenStream) -> TokenStream {
let input = syn::parse_macro_input!(input);
pin_project::attribute(args.into(), input).into()
pin_project::attribute(&args.into(), input.into()).into()
}

/// An attribute for annotating an impl block that implements [`Drop`].
Expand Down Expand Up @@ -538,9 +537,9 @@ pub fn project_ref(args: TokenStream, input: TokenStream) -> TokenStream {
project::attribute(&args.into(), input, Immutable).into()
}

/// An internal helper macro.
#[doc(hidden)]
#[proc_macro_derive(__PinProjectAutoImplUnpin, attributes(pin))]
pub fn derive_unpin(input: TokenStream) -> TokenStream {
let input = syn::parse_macro_input!(input);
pin_project::derive(input).into()
#[proc_macro_derive(__PinProjectInternalDerive, attributes(pin))]
pub fn __pin_project_internal_derive(input: TokenStream) -> TokenStream {
pin_project::derive(input.into()).into()
}
Loading