typescript-definitions icon indicating copy to clipboard operation
typescript-definitions copied to clipboard

error: proc-macro derive produced unparseable tokens

Open masonk opened this issue 4 years ago • 6 comments

This is a cool project. Thanks for releasing it! I am getting an error in typescript.rs:40.

I can trigger this with a very simple main.rs:

use serde::{Deserialize, Serialize};
use typescript_definitions::{TypeScriptify, TypeScriptifyTrait};

fn main() {
    #[derive(Debug, Serialize, Deserialize, TypeScriptify)]
    struct Foo {
        num: i64,
    }

    println!("{}", Foo::type_script_ify());
}
error: proc-macro derive produced unparseable tokens
  --> /home/mason/.cargo/registry/src/github.com-1ecc6299db9ec823/typescript-definitions-derive-0.1.10/src/typescript.rs:40:10
   |
$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home:  /home/mason/.rustup

nightly-x86_64-unknown-linux-gnu (default)
rustc 1.41.0-nightly (412f43ac5 2019-11-24)

masonk avatar Nov 25 '19 05:11 masonk

~~Seems to be related to pest-parser/pest#427~~ (it is not related to this, not in the least).

onelson avatar Dec 01 '19 03:12 onelson

Looking closer, it was suggested the issue reported to pest was caused by ambigious module names (which is not the case here as far as I can tell). Just to rule it out, I fussed with the use statements and the path in the derive attribute itself to no avail. I'm not exactly sure what the issue is.

onelson avatar Dec 01 '19 04:12 onelson

I still don't have any real solutions, but what I see in master right now.

I can get the crate to build...

  • if I set my toolchain to a version older than nightly-2019-11-25 (nightly-2019-11-24 works).
  • and if I apply the following patch:
diff --git a/typescript-definitions-derive/src/attrs.rs b/typescript-definitions-derive/src/attrs.rs
index 83a6867..43b3546 100644
--- a/typescript-definitions-derive/src/attrs.rs
+++ b/typescript-definitions-derive/src/attrs.rs
@@ -12,7 +12,6 @@ use quote::quote;
 use proc_macro2::TokenStream;
 use syn::{Attribute, Ident, Lit, Meta, /* MetaList,*/ MetaNameValue, NestedMeta};
 
-#[derive(Debug)]
 pub struct Attrs {
     pub comments: Vec<String>,
     pub guard: bool,

The removal of the derived Debug trait is needed since apparently syn::Type does not implement Debug.

onelson avatar Dec 01 '19 06:12 onelson

Short-term fix: rename the union rule.

I'm looking into what changed and will report a bug to upstream rust for this changed behavior.

CAD97 avatar Dec 02 '19 01:12 CAD97

Thanks @CAD97. I'll keep my toolchain pinned for now and track the upstream bug on rust for progress. Probably doesn't make much sense to patch around this immediately if holding the toolchain back is enough for now.

onelson avatar Dec 02 '19 02:12 onelson

Looks like the "unparsable tokens" issue should be fixed as of 2 days ago since rust-lang/rust#66943 has been merged through. We should be able to track nightly freely once more.

onelson avatar Dec 09 '19 00:12 onelson