typescript-definitions
typescript-definitions copied to clipboard
error: proc-macro derive produced unparseable tokens
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)
~~Seems to be related to pest-parser/pest#427~~ (it is not related to this, not in the least).
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.
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
.
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.
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.
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.