You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a project that tries to use prost and I have another dependency that uses the "nightly" feature of proc-macro2 which makes it a wrapper around the compiler's inner proc-macro crate.
The biggest difference is in handling spans.
While in the current version Span::def_site() and Span::call_site() is the same, it's really different in the nightly version.
I think at most of the places prost cannot use the quote! macro and Ident::from because that makes them "hygienic" so they cannot use anything from outside the macros and they cannot export anything outside of the macro.
If you run cargo build inside the tests dir, you get thousands of errors because of this.
To fix this prost should use quote_spanned!(Span::call_site()=> ...) and Ident::new(&..., Span::call_site()) at most places.
Please take a look at the discussion here about this difference: rust-lang/rust#45934
I found a quick and dirty workaround to try to use call_site() in all quote!s by overriding the macro like this:
The thousands of errors disappear after this, but there are a few new ones:
Compiling tests v0.0.0 (file:///home/ngg/git/prost/tests)
error: int literal is too large
--> /home/ngg/git/prost/target/debug/build/tests-b935ebcf576482e1/out/protobuf_unittest.rs:3:28
|
3 | #[derive(Clone, PartialEq, Message)]
| ^^^^^^^
error: proc-macro derive produced unparseable tokens
--> /home/ngg/git/prost/target/debug/build/tests-b935ebcf576482e1/out/protobuf_unittest.rs:3:28
|
3 | #[derive(Clone, PartialEq, Message)]
| ^^^^^^^
error: Could not compile `tests`.
I've tried to change the few explicit Span::def_site() references into Span::call_site() and all Ident::from(...) into Ident::new(&..., Span::call_site()) but unfortunately these didn't fix the problem.
I have not yet debugged it further, I'd like to ask for your opinion before.
I don't think this is really urgent, but it will need to be handled somehow.
rust-lang/rust#48889 has been fixed in latest nightly, and with the new proc-macro2 0.3.x it is really easy to be compatible with both the stable and nightly macros, I've simplified my pull request #89. Please consider merging it!
I have a project that tries to use prost and I have another dependency that uses the "nightly" feature of proc-macro2 which makes it a wrapper around the compiler's inner proc-macro crate.
The biggest difference is in handling spans.
While in the current version
Span::def_site()
andSpan::call_site()
is the same, it's really different in the nightly version.I think at most of the places prost cannot use the
quote!
macro andIdent::from
because that makes them "hygienic" so they cannot use anything from outside the macros and they cannot export anything outside of the macro.If you run
cargo build
inside thetests
dir, you get thousands of errors because of this.To fix this prost should use
quote_spanned!(Span::call_site()=> ...)
andIdent::new(&..., Span::call_site())
at most places.Please take a look at the discussion here about this difference: rust-lang/rust#45934
I found a quick and dirty workaround to try to use call_site() in all
quote!
s by overriding the macro like this:The thousands of errors disappear after this, but there are a few new ones:
I've tried to change the few explicit
Span::def_site()
references intoSpan::call_site()
and allIdent::from(...)
intoIdent::new(&..., Span::call_site())
but unfortunately these didn't fix the problem.I have not yet debugged it further, I'd like to ask for your opinion before.
I don't think this is really urgent, but it will need to be handled somehow.
My current changes can be found here: danburkert/prost@master...ngg:nightly-proc-macro2
The text was updated successfully, but these errors were encountered: