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

prost-derive: compatible with "nightly" proc-macro2 #89

Merged
merged 1 commit into from
Apr 7, 2018

Conversation

ngg
Copy link
Contributor

@ngg ngg commented Mar 9, 2018

This fixes compatibility with proc-macro2 if it has its "nightly"
feature enabled (it can be if another crate requires it).

Closes #88.

proc-macro2 0.3 tries to be compatible with the non-nightly
0.2 versions, even if the nightly feature is enabled.

This fixes compile errors when another dependency requires the
"nightly" feature of proc-macro2.
@ngg ngg force-pushed the nightly-proc-macro2 branch from 98b552e to c237a6e Compare April 2, 2018 15:51
@ngg
Copy link
Contributor Author

ngg commented Apr 2, 2018

The new 0.3 proc-macro2 makes it easy to be compatible using different feature sets. ("nightly" versus "non-nightly"), I could revert most of the required changes by updating dependencies.

@ngg ngg changed the title prost-derive: use Span::call_site() everywhere prost-derive: compatible with "nightly" proc-macro2 Apr 2, 2018
@dflemstr
Copy link
Contributor

dflemstr commented Apr 3, 2018

It would be great to see this merged! @danburkert any blockers? I'm using the proc-macro2 branch for the last month and it seems to work fine.

@@ -696,7 +696,7 @@ impl DefaultValue {
DefaultValue::String(ref value) => quote!(#value.to_owned()),
DefaultValue::Bytes(ref value) if value.is_empty() => quote!(::std::vec::Vec::new()),
DefaultValue::Bytes(ref value) => {
let lit = LitByteStr::new(value, Span::def_site());
let lit = LitByteStr::new(value, Span::call_site());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, do you know of any resources that document what the actual difference is here? I was mostly guessing we I introduced this during the syn 0.11 to 0.12 transition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call_site() will mean what def_site() meant previously, everything is unhygienic (visible from outside the macro). The def_site() will be hygienic, invisible from outside. But that is not currently possible on stable, that's a nightly-only feature. Macros 2.0 will be finalized before Rust 2018 (so in the next few months) and after that it will be possible to write hygienic macros too.

@danburkert danburkert merged commit 7a2a545 into tokio-rs:master Apr 7, 2018
@danburkert
Copy link
Collaborator

Looks good. I tried to think of a way this could be regression tested, but came up short. @ngg do you know any ways it could be tested?

@danburkert danburkert mentioned this pull request Apr 7, 2018
@ngg
Copy link
Contributor Author

ngg commented Apr 9, 2018

Probably you could add a "nightly" feature to prost-derive which would depend on the "nightly" feature of proc-macro2 and you could run tests with this feature too on travis

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

Successfully merging this pull request may close these issues.

"nightly" feature of proc-macro2 is not working
3 participants