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

Fix compile error with dyn types #158

Merged
merged 1 commit into from
Oct 21, 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
16 changes: 8 additions & 8 deletions pin-project-internal/src/pin_project/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,21 +370,21 @@ impl<'a> Context<'a> {

let lifetime = &self.proj.lifetime;
proj_fields.push(quote! {
#vis #ident: ::core::pin::Pin<&#lifetime mut #ty>
#vis #ident: ::core::pin::Pin<&#lifetime mut (#ty)>
});
proj_ref_fields.push(quote! {
#vis #ident: ::core::pin::Pin<&#lifetime #ty>
#vis #ident: ::core::pin::Pin<&#lifetime (#ty)>
});
proj_body.push(quote! {
#ident: ::core::pin::Pin::new_unchecked(#ident)
});
} else {
let lifetime = &self.proj.lifetime;
proj_fields.push(quote! {
#vis #ident: &#lifetime mut #ty
#vis #ident: &#lifetime mut (#ty)
});
proj_ref_fields.push(quote! {
#vis #ident: &#lifetime #ty
#vis #ident: &#lifetime (#ty)
});
proj_body.push(quote! {
#ident
Expand Down Expand Up @@ -417,21 +417,21 @@ impl<'a> Context<'a> {

let lifetime = &self.proj.lifetime;
proj_fields.push(quote! {
#vis ::core::pin::Pin<&#lifetime mut #ty>
#vis ::core::pin::Pin<&#lifetime mut (#ty)>
});
proj_ref_fields.push(quote! {
#vis ::core::pin::Pin<&#lifetime #ty>
#vis ::core::pin::Pin<&#lifetime (#ty)>
});
proj_body.push(quote! {
::core::pin::Pin::new_unchecked(#id)
});
} else {
let lifetime = &self.proj.lifetime;
proj_fields.push(quote! {
#vis &#lifetime mut #ty
#vis &#lifetime mut (#ty)
});
proj_ref_fields.push(quote! {
#vis &#lifetime #ty
#vis &#lifetime (#ty)
});
proj_body.push(quote! {
#id
Expand Down
29 changes: 29 additions & 0 deletions tests/ui/pin_project/run-pass/dyn-type.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use pin_project::pin_project;

#[pin_project]
struct Struct1 {
a: i32,
f: dyn std::fmt::Debug,
}

#[pin_project]
struct Struct2 {
a: i32,
#[pin]
f: dyn std::fmt::Debug,
}

#[pin_project]
struct Struct3 {
a: i32,
f: dyn std::fmt::Debug + Send,
}

#[pin_project]
struct Struct4 {
a: i32,
#[pin]
f: dyn std::fmt::Debug + Send,
}

fn main() {}