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

error: proc-macro derive produced unparseable tokens #4

Open
masonk opened this issue Nov 25, 2019 · 6 comments
Open

error: proc-macro derive produced unparseable tokens #4

masonk opened this issue Nov 25, 2019 · 6 comments

Comments

@masonk
Copy link

masonk commented Nov 25, 2019

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)
@onelson
Copy link

onelson commented Dec 1, 2019

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

@onelson
Copy link

onelson commented Dec 1, 2019

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
Copy link

onelson commented Dec 1, 2019

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.

@CAD97
Copy link

CAD97 commented Dec 2, 2019

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.

@onelson
Copy link

onelson commented Dec 2, 2019

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
Copy link

onelson commented Dec 9, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants