taiki-e / pin-project-lite

A lightweight version of pin-project written with declarative macros.
https://docs.rs/pin-project-lite
Apache License 2.0
226 stars 16 forks source link

Compile error when there are field-level doccomments #41

Closed nightkr closed 3 years ago

nightkr commented 3 years ago
use pin_project_lite::pin_project;

pin_project! {
    struct Foo {
        /// asdf
        bar: String,
    }
}

fails to compile, with the error message:

error: no rules expected the token `[`
 --> src/foo.rs:3:1
  |
3 | / pin_project! {
4 | |     struct Foo {
5 | |         /// asdf
6 | |         bar: String,
7 | |     }
8 | | }
  | |_^ no rules expected this token in macro call
  |
  = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

This version (without the doccomment) compiles just fine:

use pin_project_lite::pin_project;

pin_project! {
    struct Foo {
        bar: String,
    }
}
taiki-e commented 3 years ago

This is a known limitation (#3, due to doc comment will be passed as #[doc] to macro), see https://github.com/taiki-e/pin-project-lite/issues/3#issuecomment-745194112 for the workaround.

nightkr commented 3 years ago

Ah, managed to miss that. Oh well. Guess I should close this since it doesn't really add anything new.