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

Fix compile error with dyn types #158

merged 1 commit into from
Oct 21, 2019

Conversation

oxalica
Copy link
Contributor

@oxalica oxalica commented Oct 21, 2019

Add parentheses around original types in generated code.

Currently, it will cause a compile error when field type is like dyn Trait1 + Trait2.

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

will result in,

error: ambiguous `+` in a type
 --> src/main.rs:6:8
  |
6 |     f: dyn std::fmt::Debug + Send,
  |        ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(dyn std::fmt::Debug + Send)`

error: proc-macro derive produced unparseable tokens
 --> src/main.rs:2:1
  |
2 | #[pin_project]
  | ^^^^^^^^^^^^^^

@taiki-e
Copy link
Owner

taiki-e commented Oct 21, 2019

Thanks!

bors r+

bors bot added a commit that referenced this pull request Oct 21, 2019
158: Fix compile error with `dyn` types r=taiki-e a=oxalica

Add parentheses around original types in generated code.

Currently, it will cause a compile error when field type is like `dyn Trait1 + Trait2`.
```rust
use pin_project::pin_project;
#[pin_project]
struct Struct {
    a: i32,
    #[pin]
    f: dyn std::fmt::Debug + Send,
}
```
will result in,
```
error: ambiguous `+` in a type
 --> src/main.rs:6:8
  |
6 |     f: dyn std::fmt::Debug + Send,
  |        ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(dyn std::fmt::Debug + Send)`

error: proc-macro derive produced unparseable tokens
 --> src/main.rs:2:1
  |
2 | #[pin_project]
  | ^^^^^^^^^^^^^^
```


Co-authored-by: oxalica <oxalicc@pm.me>
@taiki-e
Copy link
Owner

taiki-e commented Oct 21, 2019

bors retry
(seems bors crashed)

bors bot added a commit that referenced this pull request Oct 21, 2019
158: Fix compile error with `dyn` types r=taiki-e a=oxalica

Add parentheses around original types in generated code.

Currently, it will cause a compile error when field type is like `dyn Trait1 + Trait2`.
```rust
use pin_project::pin_project;
#[pin_project]
struct Struct {
    a: i32,
    #[pin]
    f: dyn std::fmt::Debug + Send,
}
```
will result in,
```
error: ambiguous `+` in a type
 --> src/main.rs:6:8
  |
6 |     f: dyn std::fmt::Debug + Send,
  |        ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(dyn std::fmt::Debug + Send)`

error: proc-macro derive produced unparseable tokens
 --> src/main.rs:2:1
  |
2 | #[pin_project]
  | ^^^^^^^^^^^^^^
```


Co-authored-by: oxalica <oxalicc@pm.me>
@bors
Copy link
Contributor

bors bot commented Oct 21, 2019

Build succeeded

  • style (rustdoc)
  • test (1.33.0)
  • test (stable)
  • test (nightly)
  • test (macos)
  • style (rustfmt)
  • style (clippy)
  • test (1.36.0)
  • test (beta)

@bors bors bot merged commit 4c1b9e5 into taiki-e:master Oct 21, 2019
@oxalica oxalica deleted the fix-dyn-field branch October 21, 2019 08:15
@taiki-e
Copy link
Owner

taiki-e commented Oct 21, 2019

Published in 0.4.5.

@taiki-e taiki-e added the A-pin-projection Area: #[pin_project] label May 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pin-projection Area: #[pin_project]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants