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

Update syn, quote and proc-macro2 #940

Merged
merged 5 commits into from
Apr 11, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions futures-macro-async/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ few other assorted macros.
proc-macro = true

[dependencies]
quote = "0.4"
proc-macro2 = "0.2"
quote = "0.5"
proc-macro2 = "0.3"

[dependencies.syn]
version = "0.12.13"
features = ["full", "fold", "parsing", "printing", "extra-traits"]
version = "0.13"
features = ["full", "fold", "parsing", "printing", "extra-traits", "proc-macro"]
default-features = false

[features]
Expand Down
4 changes: 2 additions & 2 deletions futures-macro-async/src/elision.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use proc_macro2::{Term, Span};
use proc_macro2::Span;
use syn::*;
use syn::punctuated::Punctuated;
use syn::token::Comma;
Expand Down Expand Up @@ -34,7 +34,7 @@ impl<'a> UnelideLifetimes<'a> {
// Constitute a new lifetime
fn new_lifetime(&mut self) -> Lifetime {
let lifetime_name = format!("{}{}", self.lifetime_name, self.count);
let lifetime = Lifetime::new(Term::intern(&lifetime_name), Span::call_site());
let lifetime = Lifetime::new(&lifetime_name, Span::call_site());

let idx = self.lifetime_index + self.count as usize;
self.generics.insert(idx, GenericParam::Lifetime(LifetimeDef::new(lifetime.clone())));
Expand Down
16 changes: 8 additions & 8 deletions futures-macro-async/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,19 +573,19 @@ if_nightly! {
let mut spans = Tokens::new();
tokens.to_tokens(&mut spans);
let good_tokens = proc_macro2::TokenStream::from(spans).into_iter().collect::<Vec<_>>();
let first_span = good_tokens.first().map(|t| t.span).unwrap_or(Span::def_site());
let last_span = good_tokens.last().map(|t| t.span).unwrap_or(first_span);
let first_span = good_tokens.first().map(|t| t.span()).unwrap_or(Span::call_site());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this really be call_site or better to make first_last function to return proc_macro::Span?

let last_span = good_tokens.last().map(|t| t.span()).unwrap_or(first_span);
(first_span, last_span)
}

fn respan(input: proc_macro2::TokenStream,
&(first_span, last_span): &(Span, Span)) -> proc_macro2::TokenStream {
let mut new_tokens = input.into_iter().collect::<Vec<_>>();
if let Some(token) = new_tokens.first_mut() {
token.span = first_span;
token.set_span(first_span);
}
for token in new_tokens.iter_mut().skip(1) {
token.span = last_span;
token.set_span(last_span);
}
new_tokens.into_iter().collect()
}
Expand All @@ -595,8 +595,8 @@ if_nightly! {
{
let mut new_tokens = Tokens::new();
for token in input.into_iter() {
match token.kind {
proc_macro2::TokenNode::Op('!', _) => tokens.to_tokens(&mut new_tokens),
match token {
proc_macro2::TokenTree::Op(op) if op.op() == '!' => tokens.to_tokens(&mut new_tokens),
_ => token.to_tokens(&mut new_tokens),
}
}
Expand All @@ -609,8 +609,8 @@ if_nightly! {
let mut replacements = replacements.iter().cycle();
let mut new_tokens = Tokens::new();
for token in input.into_iter() {
match token.kind {
proc_macro2::TokenNode::Op('!', _) => {
match token {
proc_macro2::TokenTree::Op(op) if op.op() == '!' => {
replacements.next().unwrap().to_tokens(&mut new_tokens);
}
_ => token.to_tokens(&mut new_tokens),
Expand Down